/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #242836;
    --border: #2e3345;
    --text: #e4e6f0;
    --text-muted: #8b90a5;
    --accent: #6c63ff;
    --accent-hover: #817aff;
    --accent-glow: rgba(108, 99, 255, 0.15);
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ── Top Nav ──────────────────────────────────────────────────────────── */
.top-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.nav-logo { font-size: 1.3rem; }

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

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

.card h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Upload Zone ──────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-zone .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.upload-zone p { color: var(--text-muted); }
.upload-zone .hint { font-size: 0.85rem; margin-top: 0.5rem; }

input[type="file"] { display: none; }

/* ── Language Picker ──────────────────────────────────────────────────── */
.lang-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.lang-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    transition: all var(--transition);
    user-select: none;
}

.lang-chip.selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.lang-chip:hover:not(.selected) {
    border-color: var(--accent);
    color: var(--text);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 12px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

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

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.85; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* ── Metadata Grid ────────────────────────────────────────────────────── */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.meta-item {
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.meta-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.meta-item span {
    font-size: 1.05rem;
    font-weight: 500;
}

/* ── Progress Bars ────────────────────────────────────────────────────── */
.progress-list { display: flex; flex-direction: column; gap: 1rem; }

.progress-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-lang {
    min-width: 90px;
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-bar-container {
    flex: 1;
    height: 28px;
    background: var(--surface-2);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 14px;
    background: linear-gradient(90deg, var(--accent) 0%, #a78bfa 100%);
    transition: width 0.4s ease;
    min-width: 0;
}

.progress-bar-fill.complete {
    background: linear-gradient(90deg, var(--success), #22d3ee);
}

.progress-stats {
    min-width: 100px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Chapter List ─────────────────────────────────────────────────────── */
.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chapter-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.chapter-link:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.chapter-link .title { font-weight: 500; }

.chapter-link .badges {
    display: flex;
    gap: 0.35rem;
}

.badge {
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-done { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-pending { background: rgba(139, 144, 165, 0.15); color: var(--text-muted); }

/* ── Chapter Reader (side-by-side) ────────────────────────────────────── */
.reader-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.reader-header h2 { margin-bottom: 0; }

.reader-lang-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--surface-2);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.reader-lang-tab {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
    font-family: var(--font);
}

.reader-lang-tab.active {
    background: var(--accent);
    color: white;
}

.reader-lang-tab:hover:not(.active) { color: var(--text); }

.reader-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.reader-column {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.reader-column h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.reader-column .content {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.8;
    font-family: var(--font);
}

.reader-column .content.empty {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 3rem 1rem;
}

/* ── Breadcrumb / Nav ─────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { opacity: 0.5; }

/* ── Animations ───────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.translating-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.translating-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s ease infinite;
}

/* ── Empty State ──────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text); }

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .app { padding: 1rem; }
    header h1 { font-size: 1.8rem; }
    .reader-columns { grid-template-columns: 1fr; }
    .meta-grid { grid-template-columns: 1fr 1fr; }
    .progress-row { flex-wrap: wrap; }
    .progress-stats { min-width: auto; }
}
