/* ============================================================
   Scan to PDF — scan-to-pdf.css
   Prefix: stp-   Accent: #8B5CF6  (violet)
   Accent RGB: 139, 92, 246
   ============================================================ */

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

.stp-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;
}

/* ── Start Screen ─────────────────────────────────────────── */
.stp-start {
    display: flex;
    justify-content: center;
}

.stp-start-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 20px;
    padding: 48px 32px 40px;
    background: #FFFFFF;
}

.stp-start-icon {
    font-size: 3.5rem;
    color: #8B5CF6;
    opacity: 0.7;
    display: block;
    margin-bottom: 16px;
}

.stp-start-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.stp-start-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0 0 28px;
}

.stp-start-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stp-start-note {
    font-size: 0.8125rem;
    color: var(--text-light, #64748B);
    margin: 0;
}

.stp-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.stp-btn-primary:hover {
    background: #7C3AED;
}

.stp-btn-primary:disabled {
    background: var(--text-light, #64748B);
    cursor: not-allowed;
}

.stp-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    color: var(--text-primary);
    background: #F8FAFC;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    text-decoration: none;
}

.stp-btn-secondary:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

/* ── Camera View ──────────────────────────────────────────── */
.stp-camera-view {
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 16px;
    overflow: hidden;
}

.stp-camera-view[hidden] {
    display: none;
}

.stp-camera-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #F8FAFC;
    border-bottom: 1px solid rgba(100, 116, 139, 0.12);
}

.stp-cam-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.stp-cam-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Toggle switch */
.stp-checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

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

.stp-checkbox-track {
    width: 36px;
    height: 20px;
    border-radius: 12px;
    background: rgba(100, 116, 139, 0.25);
    transition: background 0.2s;
    flex-shrink: 0;
    position: relative;
}

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

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

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

.stp-filter-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.stp-btn-flip-camera {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    background: #F8FAFC;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.stp-btn-flip-camera:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.stp-btn-flip-camera[hidden] {
    display: none;
}

.stp-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #F8FAFC;
    border-bottom: 1px solid rgba(100, 116, 139, 0.12);
    flex-wrap: wrap;
}

.stp-filter-preset-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(100, 116, 139, 0.2);
    background: #FFFFFF;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}

.stp-filter-preset-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.stp-filter-preset-btn.is-active {
    background: #8B5CF6;
    border-color: #8B5CF6;
    color: #fff;
}

.stp-video-wrap {
    position: relative;
    background: #000;
}

.stp-video {
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    display: block;
}

.stp-overlay-guide {
    position: absolute;
    inset: 10%;
    border: 2px solid rgba(139, 92, 246, 0.5);
    border-radius: 8px;
    box-sizing: border-box;
    pointer-events: none;
    animation: stp-guide-pulse 2s ease-in-out infinite;
}

@keyframes stp-guide-pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.stp-capture-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10;
}

.stp-capture-countdown[hidden] {
    display: none;
}

.stp-countdown-num {
    font-size: 5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    animation: stp-countdown-pop 0.3s ease;
}

@keyframes stp-countdown-pop {
    from {
        transform: scale(1.4);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.stp-camera-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: #F8FAFC;
    border-top: 1px solid rgba(100, 116, 139, 0.12);
}

.stp-page-counter {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 60px;
}

.stp-btn-capture {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #8B5CF6;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.1s;
}

.stp-btn-capture:hover {
    transform: scale(1.07);
}

.stp-btn-capture:active {
    transform: scale(0.94);
}

.stp-capture-ring {
    position: absolute;
    font-size: 3.5rem;
    color: #8B5CF6;
}

.stp-capture-dot {
    position: absolute;
    font-size: 2.25rem;
    color: #8B5CF6;
}

.stp-btn-done {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.stp-btn-done:hover {
    background: #7C3AED;
}

.stp-btn-done:disabled {
    background: var(--text-light, #64748B);
    cursor: not-allowed;
}

.stp-footer-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-width: 64px;
}

.stp-btn-undo-last {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.stp-btn-undo-last:hover:not(:disabled) {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.stp-btn-undo-last:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Pages Panel ──────────────────────────────────────────── */
.stp-pages-panel[hidden] {
    display: none;
}

.stp-pages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.stp-pages-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stp-file-size-est {
    font-size: 0.8125rem;
    color: #8B5CF6;
    font-weight: 600;
}

.stp-file-size-est[hidden] {
    display: none;
}

.stp-pages-count {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stp-pages-hint {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.stp-pages-actions {
    display: flex;
    gap: 8px;
}

.stp-thumbs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stp-thumb {
    position: relative;
    border: 2px solid rgba(100, 116, 139, 0.14);
    border-radius: 8px;
    overflow: visible;
    cursor: default;
}

.stp-thumb-inner {
    overflow: hidden;
    border-radius: 6px;
}

.stp-thumb-img {
    width: 100%;
    display: block;
    aspect-ratio: 3/4;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.15s;
}

.stp-thumb-img:hover {
    opacity: 0.88;
}

.stp-thumb-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background: #F8FAFC;
    border-top: 1px solid rgba(100, 116, 139, 0.12);
}

.stp-thumb-num {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.stp-thumb-rot-btns {
    display: flex;
    gap: 2px;
}

.stp-thumb-rot-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    padding: 0;
    transition: background 0.12s, color 0.12s;
}

.stp-thumb-rot-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
}

.stp-thumb-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #DC2626;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.stp-thumb-remove:hover {
    background: #B91C1C;
}

/* Options row */
.stp-options-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: #FFFFFF;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 12px;
    margin-bottom: 14px;
}

.stp-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

.stp-input,
.stp-select {
    padding: 8px 12px;
    border: 1px solid rgba(100, 116, 139, 0.18);
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
}

.stp-input:focus,
.stp-select:focus {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.stp-select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7280' d='M12 15.5l-6-6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.stp-quality-val {
    font-weight: 500;
    color: #8B5CF6;
    text-transform: none;
    letter-spacing: 0;
}

.stp-quality-slider {
    width: 140px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #8B5CF6 var(--pct, 70%), rgba(100, 116, 139, 0.2) var(--pct, 70%));
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.stp-quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #8B5CF6;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

.stp-quality-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #8B5CF6;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

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

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

.stp-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(100, 116, 139, 0.14);
    border-radius: 3px;
    overflow: hidden;
}

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

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

.stp-status {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 14px;
}

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

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

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

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

.stp-download-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stp-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 24px;
    background: #8B5CF6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.stp-btn-download:hover {
    background: #7C3AED;
}

.stp-btn-download:disabled {
    background: var(--text-light, #64748B);
    cursor: not-allowed;
}

.stp-btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.stp-btn-reset:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.stp-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    border-radius: 6px;
    background: #F8FAFC;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    text-decoration: none;
}

.stp-ghost-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

/* ── Lightbox ─────────────────────────────────────────────── */
.stp-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.stp-lightbox[hidden] {
    display: none;
}

.stp-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.stp-lightbox-box {
    position: relative;
    z-index: 1;
    background: #FFFFFF;
    border-radius: 14px;
    max-width: min(92vw, 720px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.stp-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(100, 116, 139, 0.14);
    flex-shrink: 0;
}

.stp-lightbox-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stp-lightbox-actions {
    display: flex;
    gap: 6px;
}

.stp-lightbox-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(100, 116, 139, 0.14);
    background: #F8FAFC;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: border-color 0.15s, color 0.15s;
}

.stp-lightbox-btn:hover {
    border-color: #8B5CF6;
    color: #8B5CF6;
}

.stp-lightbox-close:hover {
    border-color: #DC2626;
    color: #DC2626;
}

.stp-lightbox-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: hidden;
    padding: 20px 48px;
    background: #111;
}

.stp-lightbox-img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    display: block;
    border-radius: 4px;
    user-select: none;
}

.stp-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    transition: background 0.15s;
    z-index: 2;
}

.stp-lb-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.stp-lb-nav:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.stp-lb-prev {
    left: 8px;
}

.stp-lb-next {
    right: 8px;
}

@media (max-width: 600px) {
    .stp-section {
        padding: 24px 0 60px;
    }

    .stp-start-card {
        padding: 36px 20px 28px;
    }

    .stp-thumbs-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .stp-pages-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stp-download-bar {
        flex-direction: column;
    }

    .stp-btn-download,
    .stp-btn-reset {
        justify-content: center;
    }
}