/* ============================================================
   NovelScraper – Estilos del panel de administración
   ============================================================ */

:root {
    --ns-primary:      #4f46e5;
    --ns-primary-dark: #3730a3;
    --ns-success:      #16a34a;
    --ns-warning:      #ca8a04;
    --ns-danger:       #dc2626;
    --ns-bg:           #f8f9fb;
    --ns-surface:      #ffffff;
    --ns-border:       #e5e7eb;
    --ns-text:         #1f2937;
    --ns-muted:        #6b7280;
    --ns-radius:       0.5rem;
    --ns-shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --ns-shadow:       0 4px 12px rgba(0,0,0,.10);
}

/* ── Reset base ─────────────────────────────────────────────── */
body {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: var(--ns-bg);
    color: var(--ns-text);
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
    background: linear-gradient(135deg, #312e81 0%, #4f46e5 100%);
    box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
    padding: 0.6rem 0;
}

.navbar-brand {
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--ns-border);
    border-radius: var(--ns-radius);
    box-shadow: var(--ns-shadow-sm);
    background: var(--ns-surface);
    transition: box-shadow .2s;
}

.card-header {
    background: #f9fafb;
    border-bottom: 1px solid var(--ns-border);
    padding: 0.85rem 1.25rem;
    font-size: 0.95rem;
}

/* ── Step badge ──────────────────────────────────────────────── */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--ns-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── URL input ───────────────────────────────────────────────── */
#inputUrl {
    font-family: 'Courier New', monospace;
    font-size: 0.92rem;
}

#inputUrl:focus {
    border-color: var(--ns-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

/* ── Chapter list ────────────────────────────────────────────── */
.chapter-list-container {
    max-height: 460px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ns-border) transparent;
}

.chapter-list-container::-webkit-scrollbar {
    width: 5px;
}
.chapter-list-container::-webkit-scrollbar-thumb {
    background: var(--ns-border);
    border-radius: 10px;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background .12s;
    cursor: pointer;
    gap: 0.65rem;
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover      { background: #f5f3ff; }
.chapter-item.selected   { background: #ede9fe; }
.chapter-item.filtered-out { display: none; }

.chapter-item .chapter-num {
    font-size: 0.72rem;
    color: var(--ns-muted);
    font-weight: 600;
    min-width: 2rem;
    text-align: right;
    flex-shrink: 0;
}
.chapter-item .chapter-title-text {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ns-text);
}
.chapter-item .chapter-status {
    font-size: 0.78rem;
    flex-shrink: 0;
}

/* Status del capítulo */
.status-pending  { color: var(--ns-muted); }
.status-fetching { color: var(--ns-primary); animation: pulse 1s infinite; }
.status-done     { color: var(--ns-success); }
.status-error    { color: var(--ns-danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .4; }
}

/* ── Progress log ────────────────────────────────────────────── */
.progress-log {
    background: #0f172a;
    border-radius: 0.4rem;
    padding: 0.75rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #94a3b8;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.progress-log::-webkit-scrollbar { width: 4px; }
.progress-log::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.log-line { margin-bottom: .2rem; line-height: 1.4; }
.log-line.ok      { color: #4ade80; }
.log-line.error   { color: #f87171; }
.log-line.warn    { color: #fbbf24; }
.log-line.info    { color: #60a5fa; }

/* ── Progress bar ────────────────────────────────────────────── */
.progress { border-radius: 10px; background: #e5e7eb; }
.progress-bar {
    background: linear-gradient(90deg, var(--ns-primary) 0%, #818cf8 100%);
    border-radius: 10px;
    transition: width .3s ease;
}

/* ── Download card ───────────────────────────────────────────── */
#cardDownload.border-success {
    border-color: #86efac !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}

/* ── Badges ──────────────────────────────────────────────────── */
#badgeChapterCount {
    font-size: 0.75rem;
    vertical-align: middle;
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { border-radius: var(--ns-radius); font-size: 0.9rem; }

/* ── Config modal ────────────────────────────────────────────── */
.domain-config-row {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--ns-border);
}
.domain-config-row:last-child { border-bottom: none; }
.domain-badge {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    background: #f3f4f6;
    padding: .2rem .5rem;
    border-radius: 4px;
    color: #4f46e5;
    font-weight: 600;
}

/* ── Historial modal ─────────────────────────────────────────── */
.history-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--ns-border);
    font-size: 0.875rem;
}
.history-item:last-child { border-bottom: none; }
.history-item .h-title { font-weight: 600; color: var(--ns-text); }
.history-item .h-meta  { color: var(--ns-muted); font-size: 0.78rem; margin-top: .1rem; }
.history-item a        { color: var(--ns-primary); font-size: 0.8rem; }

/* ── Loading spinner overlay ─────────────────────────────────── */
#loadingAnalyze {
    animation: fadeIn .2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Monospace inputs ────────────────────────────────────────── */
.font-monospace { font-size: 0.82rem !important; }

/* ── Responsive tweaks ───────────────────────────────────────── */
@media (max-width: 576px) {
    .chapter-item .chapter-title-text {
        font-size: 0.82rem;
    }
    .card-header .d-flex.gap-2 {
        flex-wrap: wrap;
    }
    .navbar .d-flex.gap-2 {
        gap: .35rem !important;
    }
}

/* ── Scrollbar global (Chrome/Edge) ─────────────────────────── */
::-webkit-scrollbar        { width: 7px; height: 7px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Highlight capítulo fallido en la lista ──────────────────── */
.chapter-item.has-error {
    background: #fff5f5;
}
.chapter-item.has-error .chapter-title-text {
    color: var(--ns-danger);
}
