/*
  OmniPDF - clean layout (2026-10-19)
  One column, three steps: choose file -> settings -> convert / download.
*/

:root {
    --font-main: 'Outfit', 'Inter', 'Noto Sans TC', -apple-system, 'Microsoft JhengHei', sans-serif;

    /* Dark theme (default) */
    --bg-dark: #0b1220;
    --bg-card: rgba(15, 22, 38, 0.82);
    --bg-soft: rgba(255, 255, 255, 0.05);
    --bg-field: #0d1626;
    --border-color: rgba(255, 255, 255, 0.12);
    --text-primary: #f1f5f9;
    --text-secondary: #a9b6c9;
    --text-muted: #7f8da3;

    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --accent-text: #7cb2ff;
    --accent-amber: #f59e0b;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;

    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #2f6fe0 100%);
    --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-card: 0 10px 36px rgba(0, 0, 0, 0.35);
    --page-bg: url("art/bg-dark.webp");
    --transition: all 0.2s ease;
}

[data-theme="light"] {
    --bg-dark: #eef4fc;
    --bg-card: rgba(255, 255, 255, 0.88);
    --bg-soft: rgba(15, 40, 90, 0.04);
    --bg-field: #ffffff;
    --border-color: rgba(15, 40, 90, 0.12);
    --text-primary: #0f1b33;
    --text-secondary: #475a78;
    --text-muted: #7083a0;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-text: #1d5fd0;
    --shadow-card: 0 10px 36px rgba(31, 60, 120, 0.12);
    --page-bg: url("art/bg-light.webp");
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    background-image: var(--page-bg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

img { max-width: 100%; }

/* ---------- Layout ---------- */
.app-container {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex: 0 1 auto;
    min-width: 0;
}

.brand-logo {
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

.brand-text h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-text p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.hero-art {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 440px;
    height: auto;
    margin-left: auto;
    pointer-events: none;
    user-select: none;
}

.icon-btn {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition);
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent-text);
}

/* ---------- Main card ---------- */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
}

/* ---------- Tabs ---------- */
.nav-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: var(--bg-soft);
    padding: 0.35rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 64px;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover { color: var(--text-primary); background: var(--bg-soft); }

.tab-btn.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

.tab-ico {
    width: 64px;
    height: auto;
    flex: none;
}

.tab-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tab-text strong { font-size: 1rem; font-weight: 700; }
.tab-text small { font-size: 0.78rem; opacity: 0.85; font-weight: 400; }

.tab-btn:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.btn-icon-sm:focus-visible,
.form-control:focus-visible,
.radio-tile input:focus-visible + .tile-label {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

/* One short trust line (replaces the banner and repeated notes) */
.trust-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin: 0.9rem 0 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.trust-line img { width: 44px; height: auto; flex: none; }

/* ---------- Steps ---------- */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.step { margin-top: 1.5rem; }

.step-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.step-title img { width: 36px; height: 36px; object-fit: contain; flex: none; }

/* ---------- Dropzone ---------- */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-soft);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-input-hidden { display: none; }

.dropzone-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.drop-art { width: 150px; height: 150px; object-fit: contain; flex: none; }

.drop-text h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.35rem; }
.drop-text h3 span { color: var(--accent-text); text-decoration: underline; }
.dropzone-hint { font-size: 0.875rem; color: var(--text-muted); }

/* ---------- File chip ---------- */
.file-meta-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
}

.file-meta-info { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.file-meta-info .file-icon { font-size: 2rem; color: var(--accent-rose); flex: none; }
.file-details { min-width: 0; }
.file-details h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub-details { display: flex; gap: 0.5rem; }

.badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.6rem;
    border-radius: 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ---------- Options ---------- */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem 1.25rem;
    background: var(--bg-soft);
    padding: 1.1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.options-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.option-group.span-all { grid-column: 1 / -1; }

.option-group label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.55rem;
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--bg-field);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.925rem;
    transition: var(--transition);
}

.form-control:focus { border-color: var(--accent); }
.mb-2 { margin-bottom: 0; }
#pdfCustomRangeInput { margin-top: 0.5rem; }

/* Format tiles */
.radio-tile-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.option-group label.radio-tile { position: relative; cursor: pointer; display: block; margin: 0; font-size: inherit; font-weight: 400; color: inherit; }
.radio-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.tile-label {
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    align-items: center;
    min-height: 68px;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-md);
    background: var(--bg-field);
    border: 2px solid var(--border-color);
    transition: var(--transition);
    position: relative;
}

.tile-label img { grid-row: 1 / 3; width: 48px; height: 48px; object-fit: contain; }
.tile-label b { font-size: 1rem; font-weight: 700; align-self: end; line-height: 1.2; color: var(--text-primary); }
.tile-label small { font-size: 0.78rem; color: var(--text-muted); font-weight: 400; align-self: start; }

.radio-tile:hover .tile-label { border-color: var(--accent); }

.radio-tile input:checked + .tile-label {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.radio-tile input:checked + .tile-label::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 46px;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(59, 130, 246, 0.45); }

.btn-secondary {
    background: var(--bg-soft);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }

.btn-success {
    background: var(--gradient-emerald);
    color: #fff;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.28);
}

.btn-success:hover:not(:disabled) { transform: translateY(-1px); }

.btn-lg { min-height: 56px; padding: 0.9rem 1.5rem; font-size: 1.05rem; width: 100%; }
.btn-sm { min-height: 44px; padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ---------- Progress ---------- */
.progress-card {
    margin-top: 1rem;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
}

.progress-header { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.6rem; }

.progress-bar-track { width: 100%; height: 10px; background: var(--border-color); border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--gradient-primary); border-radius: 5px; transition: width 0.2s linear; }

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ---------- Results / lists ---------- */
.results-section { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border-color); }

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.results-header h3 { font-size: 1.05rem; font-weight: 700; }
.results-header h3 i { margin-right: 0.3rem; }
.done-ico { width: 40px; height: 36px; object-fit: contain; vertical-align: middle; margin-right: 0.3rem; }

.results-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.image-results-grid, .img-sort-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.result-card, .sort-card {
    background: var(--bg-field);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
}

.result-card:hover, .sort-card:hover { border-color: var(--accent); }

.card-img-wrapper {
    width: 100%;
    height: 180px;
    background: var(--bg-soft);
    position: relative;
    overflow: hidden;
    cursor: zoom-in;
}

.card-img-wrapper img { width: 100%; height: 100%; object-fit: contain; transition: var(--transition); }
.card-img-wrapper:hover img { transform: scale(1.04); }

.page-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.card-info { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; flex-grow: 1; justify-content: space-between; }
.card-info strong { display: block; font-size: 0.85rem; word-break: break-all; }
.card-info span { display: block; font-size: 0.8rem; color: var(--text-secondary); }

.sort-actions {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: var(--bg-soft);
    border-top: 1px solid var(--border-color);
}

.btn-icon-sm {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.btn-icon-sm:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-icon-sm.danger:hover { background: var(--accent-rose); border-color: var(--accent-rose); }
.btn-icon-sm:disabled { opacity: 0.35; cursor: not-allowed; }

.section-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.9rem; }

/* Empty state: gone as soon as progress or results are shown */
.empty-state {
    margin-top: 1rem;
    padding: 1.25rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
}

.empty-state img { width: 150px; height: auto; display: block; margin: 0 auto 0.4rem; }

#pdfProgressCard:not(.hidden) ~ .empty-state,
#pdfResultsSection:not(.hidden) ~ .empty-state { display: none; }

/* ---------- Helpers ---------- */
.hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(15, 22, 38, 0.94);
    border: 1px solid var(--accent);
    color: #fff;
    padding: 0.8rem 1.1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.25s ease;
    font-size: 0.9rem;
}

.toast.error { border-color: var(--accent-rose); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---------- Lightbox ---------- */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox-modal.active { display: flex; }

.lightbox-img { max-width: 92vw; max-height: 80vh; border-radius: var(--radius-md); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); background: #fff; }

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    line-height: 1;
    color: #fff;
    cursor: pointer;
}

.lightbox-caption { margin-top: 0.9rem; color: #cbd5e1; font-size: 0.9rem; padding: 0 1rem; text-align: center; }

/* ---------- Footer ---------- */
.app-footer {
    text-align: center;
    margin-top: auto;
    padding: 1.5rem 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .hero-art { display: none; }
    .app-header { justify-content: space-between; }
}

@media (max-width: 720px) {
    .app-container { padding: 0.9rem 0.9rem 1.5rem; }
    .glass-panel { padding: 1rem; border-radius: var(--radius-lg); }
    .brand-text h1 { font-size: 1.35rem; }
    .brand-text p { font-size: 0.8rem; }
    .tab-btn { flex-direction: column; gap: 0.2rem; min-height: 84px; text-align: center; padding: 0.5rem; }
    .tab-ico { width: 52px; }
    .tab-text small { display: none; }
    .tab-text strong { font-size: 0.92rem; }
    .trust-line { text-align: left; }
    .dropzone { padding: 1rem; }
    .dropzone-content { flex-direction: column; gap: 0.5rem; text-align: center; }
    .drop-art { width: 110px; height: 110px; }
    .options-grid, .options-grid.cols-3 { grid-template-columns: 1fr; padding: 0.9rem; }
    .radio-tile-group { grid-template-columns: 1fr; }
    .file-meta-card { flex-direction: column; align-items: stretch; }
    .results-actions .btn { flex: 1 1 100%; }
    .image-results-grid, .img-sort-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
    .card-img-wrapper { height: 150px; }
    .toast-container { left: 0.9rem; right: 0.9rem; bottom: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
