/* ============================================================
   Flatten PDF — flatten-pdf.css
   Prefix: fp-   Accent: #8B5CF6 (violet)
   ============================================================ */

.fp-section {
    --tool-accent: #8B5CF6;
    --tool-accent-rgb: 139, 92, 246;
    padding: 40px 0 80px;
}

.fp-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 18px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #8B5CF6;
    margin-bottom: 12px;
}

/* ── Upload Zone ───────────────────────────────────────────── */
.fp-upload-zone {
    display: block;
    border: 2px dashed rgba(139, 92, 246, 0.3);
    border-radius: 16px;
    background: rgba(139, 92, 246, 0.03);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

.fp-upload-zone:hover,
.fp-upload-zone:focus-visible {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.07);
}

.fp-upload-zone.fp-drag-over {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.1);
}

.fp-upload-icon {
    font-size: 3rem;
    color: #8B5CF6;
    opacity: 0.65;
    margin-bottom: 14px;
    display: block;
}

.fp-upload-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.fp-upload-sub {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.fp-browse-link {
    color: #8B5CF6;
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fp-upload-formats {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #9CA3AF);
    margin: 0;
}

/* ── Workspace ─────────────────────────────────────────────── */
.fp-workspace[hidden] {
    display: none;
}

.fp-workspace--drag {
    outline: 2px dashed rgba(139, 92, 246, 0.4);
    outline-offset: 8px;
    border-radius: 16px;
}

/* ── Queue Toolbar ─────────────────────────────────────────── */
.fp-queue-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.fp-queue-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.fp-toolbar-btns {
    display: flex;
    gap: 8px;
}

.fp-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 8px;
    background: var(--bg-secondary, #F9FAFB);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.fp-toolbar-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.fp-toolbar-btn--danger:hover {
    border-color: #DC2626;
    color: #DC2626;
}

/* ── Queue List ────────────────────────────────────────────── */
.fp-queue {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.fp-queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 10px;
}

.fp-qi-icon {
    font-size: 1.375rem;
    color: #8B5CF6;
    flex-shrink: 0;
}

.fp-qi-meta {
    flex: 1;
    min-width: 0;
}

.fp-qi-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fp-qi-stats {
    font-size: 0.78125rem;
    color: var(--text-secondary);
}

.fp-qi-pages {
    color: var(--text-tertiary, #9CA3AF);
}

/* Queue item status icon */
.fp-qi-status {
    flex-shrink: 0;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
}

.fp-qi-status--waiting {
    color: var(--text-tertiary, #9CA3AF);
}

.fp-qi-status--processing {
    color: #8B5CF6;
}

.fp-qi-status--done {
    color: #16A34A;
}

.fp-qi-status--error {
    color: #DC2626;
}

@keyframes fp-spin {
    to {
        transform: rotate(360deg);
    }
}

.fp-spin {
    display: inline-block;
    animation: fp-spin 0.8s linear infinite;
}

/* Remove button */
.fp-qi-remove {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-tertiary, #9CA3AF);
    font-size: 1rem;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.fp-qi-remove:hover {
    color: #DC2626;
}

/* ── Options card ──────────────────────────────────────────── */
.fp-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 16px;
    padding: 24px 24px 20px;
    margin-bottom: 16px;
}

.fp-card[hidden] {
    display: none;
}

.fp-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 18px;
}

.fp-options-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}

.fp-option-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    padding: 12px 14px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}

.fp-option-row:hover {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.02);
}

/* Toggle switch */
.fp-checkbox-wrap {
    align-items: center;
}

.fp-native-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.fp-checkbox-track {
    width: 40px;
    height: 22px;
    border-radius: 12px;
    background: var(--border-color, #D1D5DB);
    transition: background 0.2s;
    flex-shrink: 0;
    position: relative;
    margin-top: 1px;
}

.fp-checkbox-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.fp-native-checkbox:checked+.fp-checkbox-track {
    background: #8B5CF6;
}

.fp-native-checkbox:checked+.fp-checkbox-track::after {
    transform: translateX(18px);
}

.fp-option-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fp-option-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fp-option-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.fp-info-chip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: #7C3AED;
    line-height: 1.45;
}

.fp-info-chip i {
    font-size: 1rem;
    margin-top: 1px;
    flex-shrink: 0;
}

/* ── Progress ──────────────────────────────────────────────── */
.fp-progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.fp-progress-wrap[hidden] {
    display: none;
}

.fp-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-color, #E5E7EB);
    border-radius: 3px;
    overflow: hidden;
}

.fp-progress-fill {
    height: 100%;
    width: 0;
    background: #8B5CF6;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.fp-progress-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 180px;
}

/* ── Status ────────────────────────────────────────────────── */
.fp-status {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.fp-status[hidden] {
    display: none;
}

.fp-status--success {
    background: rgba(22, 163, 74, 0.08);
    border: 1px solid rgba(22, 163, 74, 0.25);
    color: #15803D;
}

.fp-status--error {
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #B91C1C;
}

.fp-status--info {
    background: rgba(139, 92, 246, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: #7C3AED;
}

/* ── Action bar ────────────────────────────────────────────── */
.fp-action-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 12px;
}

.fp-output-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

.fp-output-label {
    font-size: 0.78125rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fp-output-input-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.fp-output-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-right: none;
    border-radius: 8px 0 0 8px;
    background: var(--bg-input, #fff);
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}

.fp-output-input:focus {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    z-index: 1;
    position: relative;
}

.fp-output-ext {
    padding: 8px 12px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 0 8px 8px 0;
    background: var(--bg-secondary, #F9FAFB);
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.fp-btn-apply {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.fp-btn-apply:hover {
    background: #7C3AED;
}

.fp-btn-apply:disabled {
    background: var(--text-tertiary, #9CA3AF);
    cursor: not-allowed;
}

/* ── Flatten Mode card ──────────────────────────────────────── */
.fp-mode-card {
    margin-bottom: 12px;
}

.fp-mode-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.fp-mode-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px 14px;
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}

.fp-mode-row:hover {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.02);
}

.fp-native-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.fp-radio-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-color, #D1D5DB);
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
    transition: border-color 0.15s;
}

.fp-radio-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8B5CF6;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s;
}

.fp-native-radio:checked~.fp-radio-dot {
    border-color: #8B5CF6;
}

.fp-native-radio:checked~.fp-radio-dot::after {
    transform: translate(-50%, -50%) scale(1);
}

.fp-mode-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 20px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #8B5CF6;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

/* ── DPI selector ───────────────────────────────────────────── */
.fp-dpi-wrap {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, #E5E7EB);
}

.fp-dpi-wrap[hidden] {
    display: none;
}

.fp-dpi-label {
    display: block;
    font-size: 0.78125rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

.fp-dpi-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fp-dpi-option {
    position: relative;
    cursor: pointer;
}

.fp-dpi-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 9px 14px;
    border: 1.5px solid var(--border-color, #E5E7EB);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary, #F9FAFB);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    min-width: 72px;
    text-align: center;
}

.fp-dpi-hint {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-tertiary, #9CA3AF);
    letter-spacing: 0.01em;
}

.fp-dpi-option input[type="radio"]:checked+.fp-dpi-btn {
    border-color: #8B5CF6;
    color: #8B5CF6;
    background: rgba(139, 92, 246, 0.06);
}

.fp-dpi-option input[type="radio"]:checked+.fp-dpi-btn .fp-dpi-hint {
    color: #7C3AED;
}

.fp-dpi-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .fp-section {
        padding: 24px 0 60px;
    }

    .fp-upload-zone {
        padding: 40px 16px;
    }

    .fp-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .fp-btn-apply {
        justify-content: center;
    }

    .fp-dpi-list {
        gap: 6px;
    }

    .fp-dpi-btn {
        min-width: 62px;
        padding: 8px 10px;
    }

    .fp-output-wrap {
        min-width: unset;
    }

    .fp-queue-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}