/* ============================================================
   Elrhome — thème media center sombre
   ============================================================ */

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

:root {
    --bg-0: #070b15;
    --bg-1: #0e1528;
    --surface: rgba(17, 25, 45, 0.72);
    --surface-2: rgba(10, 16, 32, 0.6);
    --border: rgba(148, 163, 200, 0.12);
    --border-strong: rgba(148, 163, 200, 0.28);
    --ink: #eef2fb;
    --ink-2: #aab6d3;
    --ink-3: #7684a6;
    --accent-1: #6366f1;
    --accent-2: #a855f7;
    --good: #34d399;
    --warn: #fbbf24;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--ink);
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(ellipse 900px 500px at 15% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
        radial-gradient(ellipse 800px 500px at 95% 5%, rgba(168, 85, 247, 0.14), transparent 60%),
        linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 100%);
    background-attachment: fixed;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

/* --- En-tête + stats --- */

.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px 30px;
    margin-bottom: 24px;
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.hero-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

h1 {
    font-size: 1.9em;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.mode-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-badge.local {
    background: rgba(52, 211, 153, 0.15);
    color: var(--good);
    border: 1px solid rgba(52, 211, 153, 0.35);
}

.mode-badge.public {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.stat-tile {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    color: var(--ink-3);
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stat-value {
    color: var(--ink);
    font-size: 1.45em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-sub {
    color: var(--ink-3);
    font-size: 0.55em;
    font-weight: 500;
}

.stat-gauge {
    margin-top: 8px;
    height: 5px;
    border-radius: 3px;
    background: rgba(148, 163, 200, 0.12);
    overflow: hidden;
}

.stat-gauge-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}

/* --- Grille médias deux colonnes --- */

.media-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
}

.panel-title {
    font-size: 1.15em;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-count {
    color: var(--ink-3);
    font-size: 0.78em;
    font-weight: 500;
}

.subpanel-title {
    color: var(--ink-2);
    font-size: 0.92em;
    font-weight: 600;
    margin: 20px 0 12px;
}

.subpanel-title:first-of-type {
    margin-top: 0;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.78em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.badge-movie {
    background: rgba(99, 102, 241, 0.16);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-episode {
    background: rgba(168, 85, 247, 0.16);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* --- Téléchargements --- */

.download-row {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.download-row:first-of-type {
    border-top: none;
    padding-top: 0;
}

.dl-poster {
    width: 58px;
    height: 87px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.dl-poster-fallback,
.poster-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    background: var(--surface-2);
}

.dl-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.dl-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dl-title {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dl-pct {
    color: var(--ink-2);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    font-size: 0.95em;
}

.progress-track {
    height: 7px;
    border-radius: 4px;
    background: rgba(148, 163, 200, 0.12);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.45);
    transition: width 0.6s ease;
}

.download-row.is-warning .progress-fill {
    background: linear-gradient(90deg, #d97706, var(--warn));
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}

.dl-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--ink-3);
    font-size: 0.85em;
}

.warning-tag {
    color: var(--warn);
    font-weight: 600;
}

/* --- En attente : films (affiches) --- */

.poster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 12px;
}

.poster-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.poster-img {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border-strong);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease;
}

.poster-card:hover .poster-img {
    transform: translateY(-3px) scale(1.02);
}

.poster-card figcaption {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.poster-title {
    color: var(--ink-2);
    font-size: 0.78em;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poster-year {
    color: var(--ink-3);
    font-size: 0.72em;
}

/* --- En attente : séries --- */

.series-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.series-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.series-poster {
    width: 38px;
    height: 57px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
}

.series-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.series-title {
    font-weight: 600;
    font-size: 0.92em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.series-detail {
    color: var(--ink-3);
    font-size: 0.8em;
    font-variant-numeric: tabular-nums;
}

.missing-more-note {
    margin-top: 12px;
    color: var(--ink-3);
    font-size: 0.85em;
}

.error-note {
    margin-top: 14px;
    color: var(--warn);
    font-size: 0.85em;
}

.empty-note {
    color: var(--ink-3);
    font-size: 0.92em;
}

/* --- Services --- */

.section-title {
    font-size: 1.15em;
    font-weight: 700;
    margin-bottom: 16px;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}

.service-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    backdrop-filter: blur(12px);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.service-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    background: rgba(24, 33, 58, 0.82);
}

.service-icon {
    font-size: 1.5em;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.service-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.service-name {
    color: var(--ink);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-detail {
    color: var(--ink-3);
    font-size: 0.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ink-3);
    flex-shrink: 0;
}

.service-status.running {
    background: var(--good);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

/* --- États vides / pied de page --- */

.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 60px 30px;
    text-align: center;
}

.empty-state-icon {
    font-size: 3.4em;
    margin-bottom: 16px;
}

.empty-state h2 {
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--ink-3);
}

.footer {
    text-align: center;
    margin-top: 28px;
    color: var(--ink-3);
    font-size: 0.85em;
}

.footer-sub {
    margin-top: 4px;
    opacity: 0.75;
}

/* --- Responsive --- */

@media (max-width: 980px) {
    .media-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    body {
        padding: 14px;
    }

    h1 {
        font-size: 1.5em;
    }

    .hero {
        padding: 20px;
    }

    .dl-head {
        flex-wrap: wrap;
    }

    .dl-title {
        white-space: normal;
    }

    .services-grid {
        grid-template-columns: 1fr 1fr;
    }
}
