/* ============================================================
   CinéTrack — Feuille de styles principale
   Thème sombre, accent orange, mobile first
   ============================================================ */

/* ---------- 1. Variables de design (tokens) ---------- */
:root {
    --bg: #080e15;
    --surface-1: #121a23;
    --surface-2: #19222d;
    --accent: #ffa000;
    --accent-text: #0a0e13;
    --text: #f5f6f7;
    --text-muted: #a6adb7;
    --danger: #f2999b;
    --border: rgba(255, 255, 255, 0.08);

    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --nav-height: 64px;

    --font:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
}

/* ---------- 2. Reset léger ---------- */
* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
}
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
img {
    max-width: 100%;
    display: block;
}
a {
    color: inherit;
    text-decoration: none;
}

/* ---------- 3. Mise en page ---------- */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 22px 16px calc(var(--nav-height) + 24px);
}
h1 {
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}
h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 26px 0 12px;
}
h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}
p {
    margin: 0 0 12px;
}
.text-muted {
    color: var(--text-muted);
}

/* ---------- 4. Boutons ---------- */
.btn,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
    transition: filter 0.15s;
}
.btn:hover,
button[type="submit"]:hover {
    filter: brightness(1.12);
}
.btn-primary,
button[type="submit"].btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}
.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-danger {
    background: var(--danger);
    color: #3a0d0e;
}
.btn-block {
    width: 100%;
}

/* ---------- 5. Formulaires ---------- */
label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 14px 0 6px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}
textarea {
    resize: vertical;
    min-height: 90px;
}
input[type="checkbox"] {
    accent-color: var(--accent);
    width: auto;
}

/* ---------- 6. Cartes ---------- */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}

/* ---------- 7. Grille de films ---------- */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.movie-card {
    display: flex;
    flex-direction: column;
    background: var(--surface-1);
    border-radius: var(--radius);
    overflow: hidden;
}
.movie-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--surface-2);
}
.movie-card .no-poster {
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--surface-2);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}
.movie-card h3 {
    font-size: 0.95rem;
    margin: 10px 10px 2px;
}
.movie-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 10px 12px;
}

/* ---------- 8. En-tête de section ---------- */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 26px 0 8px;
}
.section-head h2 {
    margin: 0;
}
.section-head a {
    color: var(--accent);
    font-size: 0.85rem;
}

/* ---------- 9. Barre de recherche + chips ---------- */
.searchbar {
    display: flex;
    gap: 10px;
    margin: 8px 0 14px;
}
.searchbar input {
    flex: 1;
}
.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.chip {
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.85rem;
    border: 1px solid var(--border);
}
.chip.active {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

/* ---------- 10. Messages flash ---------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 0.9rem;
}
.flash-success {
    background: rgba(255, 160, 0, 0.12);
    border: 1px solid var(--accent);
}
.flash-error {
    background: rgba(242, 153, 155, 0.12);
    border: 1px solid var(--danger);
}

/* ---------- 11. Tableaux (admin) ---------- */
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
th {
    color: var(--text-muted);
    font-weight: 600;
}

/* ---------- 12. Barre de navigation inférieure ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(18, 26, 35, 0.96);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 0.68rem;
}
.bottom-nav a.active {
    color: var(--accent);
}
.bottom-nav svg {
    width: 22px;
    height: 22px;
}

/* ============================================================
   13. Adaptation desktop (grand écran)
   Mobile first : tout ce qui précède reste la base inchangée.
   À partir de 900px : nav en haut + mise en page élargie.
   ============================================================ */

/* Mobile : le logo de la nav reste masqué (nav à icônes en bas) */
.nav-brand {
    display: none;
}

@media (min-width: 900px) {
    /* Conteneur plus large ; la nav étant en haut, on ajuste les marges */
    .container {
        max-width: 1200px;
        padding: 96px 32px 48px;
    }

    /* La barre de navigation passe tout en haut, à l'horizontale */
    .bottom-nav {
        top: 0;
        bottom: auto;
        height: 68px;
        border-top: none;
        border-bottom: 1px solid var(--border);
        align-items: center;
        padding: 0 clamp(20px, 4vw, 48px);
        gap: 10px;
    }

    /* Logo à gauche ; margin-right:auto pousse les liens à droite */
    .nav-brand {
        display: inline-flex;
        align-items: center;
        margin-right: auto;
        font-size: 1.3rem;
        font-weight: 800;
        letter-spacing: -0.02em;
        color: var(--accent);
    }

    /* Les liens deviennent des pastilles (comme sur ta maquette) */
    .bottom-nav a {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 0;
        padding: 9px 18px;
        font-size: 0.9rem;
        color: var(--text);
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: var(--radius-pill);
    }
    .bottom-nav a:hover {
        filter: brightness(1.15);
    }
    .bottom-nav a.active {
        background: var(--accent);
        color: var(--accent-text);
        border-color: var(--accent);
    }

    /* Le logo ne doit pas ressembler à une pastille */
    .bottom-nav .nav-brand {
        background: none;
        border: none;
        padding: 0;
    }
    .bottom-nav .nav-brand:hover {
        filter: none;
    }

    /* En version bureau, on masque les icônes de la nav */
    .bottom-nav svg {
        display: none;
    }

    /* Grille de films : 4 par ligne en desktop */
    .movie-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    /* Titres un peu plus affirmés */
    h1 {
        font-size: 2.2rem;
    }
    /* ---------- 14. Pagination ---------- */
    .pagination {
        align-items: center;
        display: flex;
        justify-content: center;
        gap: 16px;
        margin: 28px 0 8px;
        font-size: 0.9rem;
    }
    .pagination a {
        padding: 10px 18px;
        border-radius: var(--radius-pill);
        background: var(--surface-2);
        border: 1px solid var(--border);
        color: var(--text);
        transition: filter 0.15s;
    }
    .pagination a:hover {
        filter: brightness(1.15);
    }
    .pagination span {
        color: var(--text-muted);
    }
    /* ---------- 15. Fiche film ---------- */
    .back-link {
        color: var(--text-muted);
        font-size: 0.9rem;
        display: inline-block;
        margin-bottom: 12px;
    }
    .meta-line {
        margin-bottom: 16px;
    }
    .fiche-poster {
        position: relative;
        max-width: 360px;
        margin: 0 auto 18px;
    }
    .fiche-poster img,
    .fiche-poster .no-poster {
        width: 100%;
        aspect-ratio: 2/3;
        object-fit: cover;
        border-radius: var(--radius-lg);
        background: var(--surface-2);
    }
    .fiche-poster .no-poster {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
    }
    .rating-badge {
        position: absolute;
        top: 12px;
        right: 12px;
        background: rgba(8, 14, 21, 0.85);
        color: var(--accent);
        font-weight: 700;
        padding: 6px 12px;
        border-radius: var(--radius-pill);
        font-size: 0.9rem;
    }
    .action-row {
        display: flex;
        gap: 12px;
        margin-bottom: 8px;
    }
    .action-row form {
        flex: 1;
    }
    .cast-row {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding-bottom: 8px;
    }
    .cast-card {
        flex: 0 0 90px;
        text-align: center;
    }
    .cast-card img,
    .cast-card .no-photo {
        width: 90px;
        height: 90px;
        border-radius: 50%;
        object-fit: cover;
        background: var(--surface-2);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
    }
    .cast-card strong {
        display: block;
        font-size: 0.8rem;
        margin-top: 6px;
    }
    .cast-card span {
        font-size: 0.72rem;
    }
    .card form button[type="submit"] {
        margin-top: 16px;
    }
    .review-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .review .rating {
        color: var(--accent);
        font-weight: 600;
    }
    .review-date {
        font-size: 0.8rem;
    }

    /* Desktop : fiche en deux colonnes (affiche | infos) */
    @media (min-width: 900px) {
        .fiche {
            display: grid;
            grid-template-columns: 320px 1fr;
            gap: 32px;
            align-items: start;
            margin-top: 8px;
        }
        .fiche-poster {
            margin: 0;
            max-width: none;
        }
        .fiche-info h1 {
            margin-top: 0;
        }
    }
    .review-actions {
        display: flex;
        gap: 14px;
        flex-wrap: wrap;
    }
    /* ---------- 16. Pages d'authentification ---------- */
    .auth-layout {
        max-width: 460px;
        margin: 0 auto;
        min-height: 70vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .auth-form h1 {
        margin-bottom: 8px;
    }
    .auth-actions {
        display: flex;
        gap: 12px;
        margin-top: 10px;
    }
    .auth-actions .btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 12px 10px;
    }

    /* Le panneau promo est masqué en mobile (formulaire seul) */
    .promo-panel {
        display: none;
    }

    @media (min-width: 900px) {
        .auth-layout {
            max-width: 960px;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 40px;
            align-items: center;
        }
        .auth-form {
            max-width: 440px;
        }

        .promo-panel {
            display: block;
            background: var(--surface-1);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 32px;
        }
        .promo-panel h2 {
            margin-top: 0;
            font-size: 1.6rem;
        }
        .promo-panel .promo-tag {
            display: block;
            margin-top: 18px;
            color: var(--accent);
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.08em;
        }
    }
    /* ---------- 17. Watchlist ---------- */
    .link-accent {
        color: var(--accent);
    }
    .movie-card.watched img {
        opacity: 0.5;
    }
    .movie-card .status {
        font-size: 0.8rem;
        color: var(--text-muted);
        margin: 0 10px 8px;
    }
    .watchlist-action {
        padding: 0 10px 10px;
    }
    .watchlist-action .btn {
        font-size: 0.8rem;
        padding: 8px;
    }
    /* ---------- 18. Profil ---------- */
    .stats-grid {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
        margin: 18px 0;
    }
    .stat-card {
        flex: 1;
        min-width: 80px;
        background: var(--surface-1);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 14px;
        text-align: center;
    }
    .stat-num {
        display: block;
        font-size: 1.7rem;
        font-weight: 700;
        color: var(--accent);
    }
    .stat-label {
        font-size: 0.75rem;
        color: var(--text-muted);
    }

    .profile-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }
    .profile-actions .btn {
        width: 100%;
    }

    .review-rating-accent {
        color: var(--accent);
        font-weight: 600;
    }
    .review-comment {
        margin-top: 6px;
    }

    /* Desktop : boutons d'action en ligne, taille auto (plus « massif ») */
    @media (min-width: 900px) {
        .profile-actions {
            flex-direction: row;
            flex-wrap: wrap;
        }
        .profile-actions .btn {
            width: auto;
        }
    }
    /* ---------- 19. Admin & utilitaires ---------- */
    .btn-sm {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    .table-card {
        overflow-x: auto;
    }
    .input-inline {
        width: auto;
    }
    .card.is-hidden {
        opacity: 0.6;
    }
    .review-hidden-tag {
        color: var(--danger);
        font-weight: 600;
    }
    .mod-actions {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        margin-top: 10px;
    }
    .mod-hide-form {
        display: flex;
        gap: 6px;
    }
    /* ---------- 20. Pages d'état (404, etc.) ---------- */
    .state-page {
        text-align: center;
        max-width: 520px;
        margin: 0 auto;
        min-height: 60vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .state-card {
        background: var(--surface-1);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 28px;
        margin-top: 18px;
    }
    .state-code {
        display: block;
        font-size: 3rem;
        font-weight: 800;
        color: var(--accent);
        margin-bottom: 8px;
    }
    .state-card .btn {
        margin-top: 12px;
    }
}
