/* ==========================================================
   CineBaseCloud — Direction artistique NOCTURNE
   Chargé EN DERNIER : redéfinit les couleurs, les polices et
   le cadre (barre du haut + onglets mobile) de toutes les pages.
   ========================================================== */

/* Un élément « hidden » reste caché, même si sa classe lui donne un display
   (ex. le bouton vide de la carte Notifications de Mon compte, classe .btn) */
[hidden] { display: none !important; }

/* ── 1. Couleurs & polices ─────────────────────────────────── */
:root,[data-theme="dark"] {
    --nc-black: #09090b;
    --nc-surface: #111114;
    --nc-card: #131316;
    --nc-card-hover: #1a1a1f;
    --nc-violet: #7c3aed;
    --nc-violet-hover: #6d28d9;
    --nc-violet-light: #a78bfa;
    --nc-violet-soft: #c4b5fd;
    --nc-violet-glow: rgba(139, 92, 246, 0.35);
    --nc-chart-1: #a78bfa;   /* graphiques : films / valeur principale */
    --nc-chart-2: #6d28d9;   /* graphiques : séries / valeur secondaire */
    --nc-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --nc-font-display: 'Inter Tight', 'Inter', -apple-system, sans-serif;
    /* Encoche / heure de l'iPhone (site installé sur l'écran d'accueil) : 0 ailleurs */
    --nc-safe-top: env(safe-area-inset-top, 0px);
    --nc-topbar-h: calc(72px + var(--nc-safe-top));
    --nc-tabbar-h: 68px;

    /* Anciens noms de variables, utilisés partout dans le site */
    --bg-primary: var(--nc-black);
    --bg-secondary: var(--nc-surface);
    --bg-card: var(--nc-card);
    --bg-card-hover: var(--nc-card-hover);
    --bg-card-deep: #0f0f12;
    --accent-gold: var(--nc-violet-light);
    --accent-gold-dim: var(--nc-violet);
    --accent-gold-glow: rgba(139, 92, 246, 0.25);
    --accent-purple: var(--nc-violet-soft);
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #8a8a93;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --gradient-gold: linear-gradient(135deg, var(--nc-violet) 0%, #8b5cf6 100%);
    --shadow-glow: 0 0 50px rgba(139, 92, 246, 0.12);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.45);
    --shadow-card-hover: 0 16px 40px rgba(0, 0, 0, 0.65);
    --glass-bg: rgba(19, 19, 22, 0.85);
    --glass-border: rgba(255, 255, 255, 0.07);
    --sidebar-bg: var(--nc-surface);
    --sidebar-active-bg: rgba(139, 92, 246, 0.1);
    --sidebar-active-border: rgba(139, 92, 246, 0.35);
}

html { background: var(--nc-black); }

body {
    font-family: var(--nc-font);
    background: var(--nc-black);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .card-title {
    font-family: var(--nc-font-display);
    letter-spacing: -0.01em;
}

::selection { background: rgba(139, 92, 246, 0.45); color: #fff; }

:focus-visible {
    outline: 2px solid var(--nc-violet-light);
    outline-offset: 2px;
}

/* Halo violet discret en haut de chaque page */
/* Dégradé radial plutôt qu'un flou de 160 px : même rendu, sans recalcul coûteux
   (un grand flou fixe saccadait le défilement sur téléphone) */
.nc-ambient {
    position: fixed;
    top: -480px;
    left: -380px;
    width: 1220px;
    height: 940px;
    background: radial-gradient(closest-side, rgba(124, 58, 237, 0.2), rgba(124, 58, 237, 0.08) 55%, rgba(124, 58, 237, 0));
    pointer-events: none;
    z-index: 0;
}

/* L'ancien décor doré et la texture ne sont plus utilisés */
.app-container::before { display: none !important; }

/* ── 2. Cadre : plus de barre latérale ─────────────────────── */
.sidebar { display: none !important; }

.app-container {
    position: relative;
    z-index: 1;
}

.main-content {
    margin-left: 0 !important;
    max-width: 1600px !important;
    width: 100%;
    margin-right: auto;
    margin-left: auto !important;
    padding: calc(var(--nc-topbar-h) + 32px) 4% 56px !important;
    box-sizing: border-box;
}

.app-footer { margin-left: 0 !important; }

/* ── 3. Barre du haut ──────────────────────────────────────── */
.nc-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    height: var(--nc-topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 4%;
    background: linear-gradient(180deg, rgba(9, 9, 11, 0.92) 0%, rgba(9, 9, 11, 0) 100%);
    transition: background-color 0.3s ease, border-color 0.3s ease, backdrop-filter 0.3s ease;
    border-bottom: 1px solid transparent;
}

.nc-topbar.scrolled {
    background: rgba(9, 9, 11, 0.82);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.nc-topbar-left,.nc-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.nc-topbar-left { gap: 40px; }

.nc-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fafafa;
    flex-shrink: 0;
}

.nc-brand-mark { width: 30px; height: 30px; display: block; }

.nc-wordmark {
    font-family: var(--nc-font-display);
    font-size: 20px;
    letter-spacing: -0.02em;
    line-height: 1;
    white-space: nowrap;
}

.nc-wordmark strong { font-weight: 800; }
.nc-wordmark span { font-weight: 500; color: var(--nc-violet-light); }

.nc-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nc-nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #a1a1aa;
    font-family: var(--nc-font);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.nc-nav-link:hover { color: #fafafa; }

.nc-nav-link.active {
    color: #fafafa;
    font-weight: 600;
}

.nc-nav-link.active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 2px;
    width: 5px;
    height: 5px;
    margin-left: -2.5px;
    border-radius: 50%;
    background: var(--nc-violet-light);
}

.nc-chevron {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}

[aria-expanded="true"] > .nc-chevron { transform: rotate(180deg); }

.nc-request-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    flex-shrink: 0;
}

/* Raccourci clavier dans le bouton « Demander un titre » */
.nc-request-btn kbd {
    font-family: var(--nc-font);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.nc-request-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--nc-violet);
    color: #ffffff;
    font-family: var(--nc-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px -10px var(--nc-violet-glow);
    flex-shrink: 0;
    white-space: nowrap;
}

.nc-request-btn:hover { background: var(--nc-violet-hover); }

.nc-avatar-btn {
    width: 44px;
    height: 44px;
    margin-left: 4px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nc-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: box-shadow 0.2s ease;
}

.nc-avatar-btn:hover .nc-avatar,.nc-avatar-btn[aria-expanded="true"] .nc-avatar {
    box-shadow: 0 0 0 2px var(--nc-violet-light);
}

.nc-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1c1a24;
    color: #fafafa;
    font-family: var(--nc-font-display);
    font-weight: 700;
    font-size: 15px;
}

.nc-login-btn {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 18px;
    border-radius: 12px;
    background: #fafafa;
    color: var(--nc-black);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
}

/* ── 4. Menus déroulants ───────────────────────────────────── */
.nc-dropdown { position: relative; }

.nc-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 950;
    min-width: 220px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(19, 19, 22, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.85);
    animation: ncMenuIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* La molette au-dessus du menu ne fait pas défiler la page derrière */
    max-height: calc(100vh - var(--nc-topbar-h) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nc-menu[hidden] { display: none; }

.nc-dropdown-right .nc-menu { left: auto; right: 0; }

@keyframes ncMenuIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.nc-menu-head {
    padding: 10px 12px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 4px;
}

.nc-menu-name { font-weight: 600; font-size: 15px; color: #fafafa; }
.nc-menu-role { font-size: 13px; color: #8a8a93; margin-top: 2px; }

.nc-menu-section { padding: 4px 0; }
.nc-menu-section + .nc-menu-section { border-top: 1px solid rgba(255, 255, 255, 0.06); }

.nc-menu-label {
    padding: 8px 12px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #8a8a93;
}

.nc-menu-item {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    color: #d4d4d8;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.nc-menu-item:hover { background: rgba(255, 255, 255, 0.06); color: #fafafa; }
.nc-menu-item.active { color: var(--nc-violet-soft); background: rgba(139, 92, 246, 0.12); }
.nc-menu-danger { color: #fca5a5; }
.nc-menu-danger:hover { background: rgba(248, 113, 113, 0.1); color: #fecaca; }

.nc-mobile-only { display: none; }

.nc-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.nc-menu-backdrop[hidden] { display: none; }

/* Bandeau « connecté en tant que » (admin) */
.nc-impersonate {
    position: fixed;
    top: var(--nc-topbar-h);
    left: 50%;
    transform: translateX(-50%);
    z-index: 899;
    padding: 8px 16px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 999px;
    background: rgba(124, 58, 237, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ede9fe;
    font-family: var(--nc-font);
    font-size: 13px;
    cursor: pointer;
}

/* ── 5. Barre d'onglets mobile ─────────────────────────────── */
.nc-tabbar { display: none; }

/* ── 6. Composants communs ─────────────────────────────────── */
.page-title {
    font-family: var(--nc-font-display) !important;
    font-size: 40px !important;
    font-weight: 700;
    letter-spacing: -0.02em !important;
    line-height: 1.05;
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
    color: #fafafa;
}

.page-subtitle { color: #a1a1aa; font-size: 15px; margin-top: 8px; }

.btn { border-radius: 12px; font-family: var(--nc-font); }

.btn-primary {
    background: var(--nc-violet) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 24px -10px var(--nc-violet-glow) !important;
}

.btn-primary:hover {
    background: var(--nc-violet-hover) !important;
    filter: none;
}

.btn-primary svg { stroke: currentColor; }

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card,.stat-card {
    background: var(--nc-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
}

.stat-card::before { display: none; }

.card:hover { border-color: rgba(255, 255, 255, 0.1); }

.stat-value { font-family: var(--nc-font-display); letter-spacing: -0.02em; }

input, select, textarea { font-family: var(--nc-font); }

/* Une notification cachée ne doit jamais bloquer les clics */
.toast:not(.show) { pointer-events: none; }

/* ── 7. Pied de page ───────────────────────────────────────── */
.app-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    background: transparent !important;
    padding: 28px 4% !important;
}

.app-footer .footer-content { max-width: 1600px; }

.nc-footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fafafa;
    text-decoration: none;
}

.nc-footer-brand img { width: 22px; height: 22px; }
.nc-footer-brand .nc-wordmark { font-size: 15px; }

.footer-tagline { font-size: 12px; color: #8a8a93; }
.footer-link, .footer-version-link, .footer-copyright { color: #8a8a93; font-size: 13px; }
.footer-link:hover, .footer-version-link:hover { color: #fafafa; }

/* ── 8. Écrans moyens ──────────────────────────────────────── */
@media (max-width: 1360px) {
    .nc-topbar-left { gap: 24px; }
    .nc-nav-link { padding: 0 9px; font-size: 14px; }
    .nc-request-btn kbd { display: none; }
}

/* Écrans étroits : le bouton « Demander un titre » passe en icône */
@media (max-width: 1000px) {
    .nc-request-btn span { display: none; }
    .nc-request-btn { width: 40px; padding: 0; justify-content: center; }
}

@media (max-width: 1000px) {
    .nc-topbar-left { gap: 14px; }
    .nc-nav-link { padding: 0 7px; }
}

@media (min-width: 861px) and (max-width: 1060px) {
    .nc-brand .nc-wordmark { display: none; }
}

/* Juste au-dessus du mobile : les liens se resserrent */
@media (min-width: 861px) and (max-width: 940px) {
    .nc-nav-link { padding: 0 5px; font-size: 13.5px; }
}

/* ── 9. Mobile ─────────────────────────────────────────────── */
@media (max-width: 860px) {
    :root { --nc-topbar-h: calc(60px + var(--nc-safe-top)); }

    .nc-topbar { padding: 0 16px; }
    .nc-nav,    .nc-request-btn { display: none; }
    .nc-wordmark { font-size: 18px; }

    .main-content {
        padding: calc(var(--nc-topbar-h) + 16px) 16px calc(var(--nc-tabbar-h) + 32px + env(safe-area-inset-bottom)) !important;
    }

    .app-footer { padding-bottom: calc(var(--nc-tabbar-h) + 24px + env(safe-area-inset-bottom)) !important; }

    .page-title { font-size: 30px !important; }

    .nc-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        height: calc(var(--nc-tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(9, 9, 11, 0.9);
        backdrop-filter: blur(20px) saturate(140%);
        -webkit-backdrop-filter: blur(20px) saturate(140%);
        border-top: 1px solid rgba(255, 255, 255, 0.07);
    }

    .nc-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border: 0;
        background: transparent;
        color: #8a8a93;
        font-family: var(--nc-font);
        font-size: 11px;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .nc-tab svg {
        width: 23px;
        height: 23px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .nc-tab.active,    .nc-tab[aria-expanded="true"] { color: var(--nc-violet-soft); }

    /* « Demander » : l'action principale, au centre, en bulle violette */
    .nc-tab > span:last-child { white-space: nowrap; letter-spacing: -0.01em; }
    .nc-tab-cta { color: #fafafa; }
    .nc-tab-cta-bubble {
        display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 32px; border-radius: 12px;
        background: var(--nc-violet); box-shadow: 0 6px 18px -8px var(--nc-violet-glow);
    }
    .nc-tab-cta .nc-tab-cta-bubble svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.4; }
    .nc-tab-cta:active .nc-tab-cta-bubble { background: var(--nc-violet-hover); }

    /* Le menu du compte devient un panneau qui monte du bas */
    .nc-user-menu {
        position: fixed;
        top: auto;
        left: 8px !important;
        right: 8px !important;
        bottom: calc(var(--nc-tabbar-h) + 8px + env(safe-area-inset-bottom));
        max-height: calc(100dvh - var(--nc-tabbar-h) - 96px);
        overflow-y: auto;
        border-radius: 20px;
        animation: ncSheetIn 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .nc-mobile-only { display: block; }

    /* Safari iOS ne bloque le défilement que si html l'est aussi ; glisser sur le voile ne fait rien */
    html:has(body.nc-sheet-open), body.nc-sheet-open { overflow: hidden; }
    .nc-menu-backdrop { touch-action: none; }

    /* Le panneau est dans la barre du haut : on la passe au premier plan
       et on retire son flou (qui empêcherait le panneau de se placer en bas) */
    body.nc-sheet-open .nc-topbar {
        z-index: 960;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .nc-impersonate { top: calc(var(--nc-topbar-h) + 4px); max-width: calc(100vw - 32px); }

    /* Bandeau cookies et notifications au-dessus des onglets */
    #cookieBanner { bottom: calc(var(--nc-tabbar-h) + 16px + env(safe-area-inset-bottom)) !important; }
    .toast { bottom: calc(var(--nc-tabbar-h) + 16px + env(safe-area-inset-bottom)) !important; }
    #pushPromptBanner {
        bottom: calc(var(--nc-tabbar-h) + 16px + env(safe-area-inset-bottom)) !important;
        left: 16px !important;
        right: 16px !important;
    }
}

@keyframes ncSheetIn {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .nc-menu, .nc-user-menu { animation: none; }
}

/* Membre suspendu pour impayé : seule la page « Mon compte » est disponible */
.is-suspended .nc-nav,
.is-suspended .nc-request-btn,
.is-suspended .nc-tabbar,
.is-suspended .nc-mobile-only { display: none !important; }

/* Bannière des cookies : jamais par-dessus la fiche d'un titre ou la recherche (elle cachait « Demander ce titre ») */
body:has(#mediaFullModal.active) #cookieBanner,
body:has(#ncSearch:not([hidden])) #cookieBanner { display: none !important; }
