:root {
    --primary: #E50914;
    --dark: #141414;
    --light: #f5f5f5;
    --card-radius: 6px;
}

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

body {
    font-family: 'Inter', Helvetica, Arial, sans-serif;
    background-color: var(--dark);
    color: var(--light);
    overflow-x: hidden;
    padding-bottom: 50px;
}

/* --- NAVBAR --- */
.navbar {
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.8) 100%);
    backdrop-filter: blur(10px);
    height: 70px; display: flex; justify-content: space-between; align-items: center;
    padding: 0 4%; position: sticky; top: 0; z-index: 2000;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.nav-left { display: flex; align-items: center; gap: 25px; }
.logo { color: var(--primary); font-size: 1.8rem; cursor: pointer; font-weight: 800; text-transform: uppercase; letter-spacing: -1px; z-index: 2002; }

.nav-links { display: flex; list-style: none; gap: 20px; }
.nav-links li { cursor: pointer; font-size: 0.95rem; color: #ccc; transition: color 0.3s; white-space: nowrap; font-weight: 500; }
.nav-links li:hover { color: white; }

/* Burger Menu (Caché sur Desktop) */
.burger-menu { display: none; font-size: 1.5rem; cursor: pointer; color: white; margin-right: 10px; z-index: 2002; }

.dropdown { position: relative; height: 100%; display: flex; align-items: center; }
.dropdown-content {
    display: none; position: absolute; background: rgba(20,20,20,0.98); border: 1px solid #333;
    min-width: 180px; top: 100%; left: 0; z-index: 2001;
    padding-top: 10px; margin-top: -5px; border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.dropdown:hover .dropdown-content { display: block; }
.dropdown-content a { display: block; padding: 10px 15px; color: #ccc; text-decoration: none; font-size: 0.9rem; cursor: pointer; transition: 0.2s; }
.dropdown-content a:hover { background: #333; color: white; }
.scrollable-dropdown { max-height: 400px; overflow-y: auto; }

/* --- SEARCH --- */
#search-form { position: relative; display: flex; align-items: center; background: rgba(255,255,255,0.1); border: 1px solid transparent; padding: 4px 10px; border-radius: 4px; transition: 0.3s; }
#search-form:focus-within { background: black; border-color: #333; }
#search-input { background: transparent; border: none; color: white; padding: 5px; outline: none; width: 220px; transition: width 0.3s; font-family: inherit; }
.search-icon { margin-right: 5px; color: #aaa; font-size: 0.9rem; }
#search-suggestions { position: absolute; top: 110%; right: 0; width: 300px; background: #1a1a1a; border: 1px solid #333; z-index: 5000; display: none; border-radius: 6px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.suggestion-item { display: flex; padding: 10px; gap: 12px; cursor: pointer; border-bottom: 1px solid #2a2a2a; transition: background 0.2s; }
.suggestion-item:hover { background: #2a2a2a; }
.suggestion-item img { width: 45px; height: 68px; object-fit: cover; border-radius: 4px; }
.s-info { display: flex; flex-direction: column; justify-content: center; }
.genre-suggestion { padding: 15px; background: #222; font-weight: bold; }

/* --- HERO --- */
.hero-slider { position: relative; height: 85vh; width: 100%; overflow: hidden; margin-bottom: -100px; }
.hero-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1s; background-size: cover; background-position: center top; pointer-events: none; }
.hero-slide.active { opacity: 1; pointer-events: auto; }
.hero-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to top, var(--dark) 10%, transparent 60%),
                linear-gradient(to right, rgba(0,0,0,0.9) 0%, transparent 60%);
    display: flex; align-items: center; padding-left: 5%;
}
.hero-content { max-width: 650px; margin-top: 80px; animation: slideUp 0.8s ease-out; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.hero-title { font-size: 4rem; margin-bottom: 15px; font-weight: 800; text-shadow: 2px 2px 10px rgba(0,0,0,0.5); line-height: 1.1; }
.hero-desc { font-size: 1.1rem; margin-bottom: 25px; text-shadow: 1px 1px 2px black; line-height: 1.6; max-height: 120px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; color: #ddd; }

.hero-actions { display: flex; gap: 15px; flex-wrap: wrap; }
.btn-hero { padding: 10px 24px; font-size: 1rem; font-weight: 600; border: none; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: transform 0.2s; font-family: inherit; }
.btn-white { background: white; color: black; }
.btn-white:hover { background: #ddd; }
.btn-gray { background: rgba(109,109,109,0.6); color: white; backdrop-filter: blur(5px); }
.btn-gray:hover { background: rgba(109,109,109,0.8); }
.btn-checked { background: rgba(70, 211, 105, 0.2); color: #46d369; border: 1px solid #46d369; }
.btn-hero:hover { transform: scale(1.05); }

/* --- CAROUSELS --- */
.category-row { margin: 20px 0; position: relative; z-index: 10; }
.category-row h2 { margin-left: 4%; font-size: 1.3rem; font-weight: 700; color: #e5e5e5; margin-bottom: 10px; }
.row-wrapper { position: relative; display: flex; align-items: center; }
.row-container { display: flex; gap: 12px; overflow-x: auto; padding: 30px 4%; scroll-behavior: smooth; scrollbar-width: none; }
.row-container::-webkit-scrollbar { display: none; }

.nav-arrow { position: absolute; top: 0; bottom: 0; width: 5%; background: rgba(20, 20, 20, 0.5); border: none; color: white; font-size: 2.5rem; cursor: pointer; z-index: 50; opacity: 0; transition: opacity 0.3s; display: flex; align-items: center; justify-content: center; }
.row-wrapper:hover .nav-arrow { opacity: 1; }
.nav-arrow:hover { background: rgba(20, 20, 20, 0.8); }
.nav-arrow.left { left: 0; background: linear-gradient(to right, #141414 0%, transparent 100%); }
.nav-arrow.right { right: 0; background: linear-gradient(to left, #141414 0%, transparent 100%); }

/* --- CARTES (Stabilisées) --- */
.card-row { min-width: 160px; height: 240px; position: relative; cursor: pointer; transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); border-radius: var(--card-radius); flex-shrink: 0; transform-origin: center center; margin: 0; }
.card-row img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--card-radius); }
/* Zoom réduit pour éviter les bugs */
.card-row:hover { transform: scale(1.1); z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }

.card-row.ranked { margin-left: 50px; overflow: visible; }
.rank-badge { position: absolute; bottom: -5px; right: 95%; font-size: 7rem; font-weight: 900; color: #000; -webkit-text-stroke: 3px #555; line-height: 0.8; z-index: -1; font-family: Impact, sans-serif; }
.card-row.ranked img { position: relative; z-index: 2; }

/* --- MODALE (Bulle) --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 4000; opacity: 0; transition: opacity 0.3s; display: flex; justify-content: center; align-items: flex-start; pointer-events: none; overflow-y: auto; padding: 50px 0; backdrop-filter: blur(5px); }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal-content { background: #181818; width: 850px; max-width: 90%; border-radius: 10px; position: relative; margin-bottom: 50px; transform: scale(0.9); transition: transform 0.3s; box-shadow: 0 25px 50px rgba(0,0,0,0.8); }
.modal-backdrop.open .modal-content { transform: scale(1); }
.modal-close { position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.5); color: white; border-radius: 50%; width: 36px; height: 36px; border: none; cursor: pointer; z-index: 10; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.modal-close:hover { background: white; color: black; }

.modal-hero { height: 450px; background-size: cover; background-position: center; position: relative; border-radius: 10px 10px 0 0; }
.modal-gradient { position: absolute; inset: 0; background: linear-gradient(0deg, #181818 0%, transparent 100%); display: flex; align-items: flex-end; padding: 40px; }
.modal-title { font-size: 3rem; font-weight: 800; text-shadow: 0 2px 4px black; margin-bottom: 15px; line-height: 1.1; }
.modal-body { padding: 30px 40px; display: grid; grid-template-columns: 2fr 1fr; gap: 40px; }
.match-score { color: #46d369; font-weight: bold; margin-right: 10px; }
.modal-similar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.sim-card { background: #2f2f2f; border-radius: 4px; overflow: hidden; cursor: pointer; transition: transform 0.2s; position:relative; }
.sim-card:hover { transform: scale(1.05); }
.sim-card img { width: 100%; height: 160px; object-fit: cover; }
.sim-info { padding: 10px; font-size: 0.85rem; color: #ddd; }

/* --- PAGE DÉTAILS RICHE --- */
#full-details-view { padding-top: 70px; min-height: 100vh; }
.fd-hero { height: 60vh; background-size: cover; background-position: center; position: relative; }
.fd-content { max-width: 1200px; margin: -100px auto 50px auto; position: relative; z-index: 10; padding: 0 4%; }
.fd-header { display: flex; gap: 40px; align-items: flex-end; margin-bottom: 40px; }
.fd-poster { width: 260px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); }
.fd-info h1 { font-size: 3.5rem; margin-bottom: 10px; font-weight: 800; text-shadow: 0 2px 10px black; line-height: 1.1; }
.fd-grid { display: grid; grid-template-columns: 70% 30%; gap: 40px; }

.full-video-section { margin-bottom: 30px; }
.video-wrapper { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; background: black; box-shadow: 0 5px 20px rgba(0,0,0,0.5); }
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.cast-list { display: flex; flex-wrap: wrap; gap: 20px; }
.cast-item { text-align: center; width: 100px; cursor: pointer; }
.cast-img { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; border: 2px solid #333; margin-bottom: 8px; transition: 0.3s; }
.cast-item:hover .cast-img { border-color: var(--primary); transform: scale(1.05); }
.cast-name { font-size: 0.9rem; color: #fff; display: block; font-weight: 600; }
.provider-icon { width: 45px; height: 45px; border-radius: 8px; margin-right: 8px; }
.meta-bar { display: flex; gap: 20px; align-items: center; margin-bottom: 25px; color: #ccc; font-size: 1rem; flex-wrap: wrap; }

/* --- PAGE ACTEUR --- */
#actor-view { padding-top: 100px; max-width: 1200px; margin: 0 auto; padding-left: 4%; padding-right: 4%; }
.actor-header { display: flex; gap: 50px; margin-bottom: 60px; align-items: flex-start; }
.actor-profile-pic img { width: 300px; border-radius: 12px; box-shadow: 0 15px 40px rgba(0,0,0,0.6); }
.actor-info h1 { font-size: 4rem; font-weight: 800; margin-bottom: 10px; letter-spacing: -1px; }
.actor-meta { color: #aaa; margin-bottom: 30px; font-size: 1.2rem; display: flex; gap: 15px; }
.actor-bio { line-height: 1.8; color: #ddd; max-width: 800px; font-size: 1.05rem; white-space: pre-line; }
.actor-filmography h2 { margin-bottom: 25px; border-bottom: 1px solid #333; padding-bottom: 15px; font-size: 1.8rem; }

/* --- GRILLES --- */
.grid-header { padding: 20px 4%; margin-top: 20px; }
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 20px; padding: 0 4% 50px 4%; }
.grid-card { transition: 0.2s; border-radius: var(--card-radius); overflow: hidden; position: relative; }
.grid-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; transition: 0.3s; }
.grid-card:hover { transform: scale(1.05); z-index: 50; box-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.loader-container { height: 80vh; display: flex; justify-content: center; align-items: center; }

/* --- FOOTER --- */
.site-footer {
    background-color: #0a0a0a; /* Plus sombre que le body */
    color: #888;
    padding: 60px 0 20px;
    font-size: 0.9rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: 50px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0 4%;
    gap: 30px;
}

.footer-col {
    flex: 1;
    min-width: 200px;
}

.footer-col h3 { color: white; margin-bottom: 15px; font-size: 1.5rem; text-transform: uppercase; }
.footer-col h4 { color: white; margin-bottom: 15px; font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; }

.footer-col ul { list-style: none; }
.footer-col ul li, .footer-col ul li a {
    margin-bottom: 10px;
    cursor: pointer;
    color: #888;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-col ul li:hover, .footer-col ul li a:hover { color: var(--primary); }

.footer-bottom {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #222;
    font-size: 0.85rem;
}

/* --- OVERLAY MENU MOBILE --- */
#menu-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 1999; opacity: 0; pointer-events: none; transition: 0.3s;
    backdrop-filter: blur(2px);
}
#menu-overlay.active { opacity: 1; pointer-events: auto; }

/* --- NAVIGATION RESPONSIVE (Fix) --- */
@media (max-width: 768px) {
    /* Menu Latéral */
    .nav-links {
        position: fixed; top: 0; left: -100%; 
        width: 80%; max-width: 300px; height: 100vh;
        background: #111; 
        flex-direction: column; 
        padding: 80px 30px; 
        gap: 30px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid #333;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
        transform: translateX(0); /* Reset pour l'animation via left */
        z-index: 2005; /* Au dessus de tout */
    }
    
    .nav-links.active { left: 0; }

    /* Bouton Burger */
    .burger-menu { 
        display: block; 
        z-index: 2010; /* Au dessus du menu ouvert */
        position: relative;
    }

    /* Dropdowns en mobile : on les affiche en statique pour simplifier */
    .dropdown-content {
        position: static;
        display: none;
        background: rgba(255,255,255,0.05);
        border: none;
        padding-left: 15px;
    }
    .dropdown.active .dropdown-content { display: block; } /* Nécessite un petit clic JS si tu veux toggle */
    
    /* Footer en colonne sur mobile */
    .footer-container { flex-direction: column; }
}

/* =========================================
   MEDIA QUERIES (RESPONSIVE TOTAL)
   ========================================= */

@media (max-width: 1024px) {
    .hero-title { font-size: 3rem; }
    .fd-info h1 { font-size: 2.8rem; }
    .modal-content { width: 95%; }
    .fd-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* NAVIGATION MOBILE */
    .burger-menu { display: block; }
    .nav-links {
        position: fixed; top: 70px; left: -100%; width: 280px; height: calc(100vh - 70px);
        background: #000; flex-direction: column; padding: 30px; gap: 25px;
        transition: 0.3s ease-in-out; border-right: 1px solid #222;
        overflow-y: auto;
    }
    .nav-links.active { left: 0; }
    .dropdown-content { position: static; background: transparent; border: none; padding-left: 20px; display: none; box-shadow: none; margin-top: 10px; }
    .dropdown:hover .dropdown-content { display: block; } 
    
    /* RECHERCHE MOBILE */
    #search-input { width: 140px; }
    #search-input:focus { width: 200px; position: absolute; right: 10px; background: #111; z-index: 5001; }

    /* HERO */
    .hero-content { margin-top: 60px; width: 100%; }
    .hero-title { font-size: 2.2rem; }
    .hero-desc { font-size: 1rem; max-height: 100px; -webkit-line-clamp: 3; }
    
    /* GRILLES & CARTES */
    .grid-container { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
    .card-row { min-width: 130px; height: 195px; } 
    .row-container { padding: 20px 4%; } 
    .rank-badge { font-size: 5rem; bottom: -5px; right: 90%; }

    /* MODALE MOBILE */
    .modal-backdrop { padding: 0; align-items: flex-end; } /* Style "Sheet" iOS */
    .modal-content { width: 100%; max-width: 100%; border-radius: 15px 15px 0 0; margin: 0; max-height: 85vh; overflow-y: auto; }
    .modal-hero { height: 250px; }
    .modal-title { font-size: 2rem; }
    .modal-body { display: flex; flex-direction: column; gap: 20px; padding: 20px; }
    .modal-similar-grid { grid-template-columns: repeat(2, 1fr); }

    /* PAGE DÉTAIL MOBILE */
    .fd-header { flex-direction: column; align-items: center; text-align: center; gap: 20px; }
    .fd-poster { width: 180px; margin-top: -50px; }
    .fd-info h1 { font-size: 2.2rem; }
    .meta-bar { justify-content: center; }
    .hero-actions { justify-content: center; }
    
    /* PAGE ACTEUR MOBILE */
    .actor-header { flex-direction: column; align-items: center; text-align: center; gap: 20px; }
    .actor-profile-pic img { width: 200px; }
    .actor-info h1 { font-size: 2.5rem; }
}

@media (max-width: 480px) {
    .logo { font-size: 1.5rem; }
    .hero-title { font-size: 1.8rem; }
    .btn-hero { padding: 8px 16px; font-size: 0.9rem; }
    
    .card-row { min-width: 110px; height: 165px; }
    .grid-container { grid-template-columns: repeat(2, 1fr); }
    
    .modal-similar-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- FIX MOBILE ET TABLETTE (max-width: 768px) --- */
@media (max-width: 768px) {
    
    /* 1. GESTION DU MENU ACCORDÉON */
    .dropdown {
        display: block;
        width: 100%;
    }

    /* Le titre du menu (ex: Genres) */
    .dropdown > span {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 0;
        cursor: pointer;
        font-size: 1.1rem;
        border-bottom: 1px solid #333;
    }

    /* Rotation de la flèche quand ouvert */
    .dropdown.mobile-active > span i {
        transform: rotate(180deg);
        transition: transform 0.3s;
    }

    /* Contenu du dropdown (caché par défaut) */
    .dropdown-content {
        position: static; /* Plus de position absolue qui flotte */
        display: none;    /* Caché */
        background: #111;
        box-shadow: none;
        border-left: 2px solid var(--primary); /* Petite barre déco */
        margin-top: 0;
        padding-left: 0;
        width: 100%;
    }

    /* Afficher quand la classe 'mobile-active' est ajoutée par le JS */
    .dropdown.mobile-active .dropdown-content {
        display: block;
        animation: slideDown 0.3s ease-out;
    }

    .dropdown-content a {
        padding: 12px 20px;
        border-bottom: 1px solid #222;
        font-size: 0.95rem;
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* 2. FIX SEARCH BAR (PETIT ÉCRAN) */
    .nav-right {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex: 1; /* Prend l'espace restant */
    }

    #search-form {
        width: auto;
        border-color: transparent;
        background: transparent;
    }

    /* Par défaut sur mobile : input caché, juste l'icône */
    #search-input {
        width: 0;
        padding: 0;
        opacity: 0;
        cursor: pointer;
    }

    /* Quand on clique/focus, l'input s'ouvre */
    #search-form.active-mobile #search-input,
    #search-input:focus {
        width: 140px; /* Largeur visible */
        padding: 5px;
        opacity: 1;
        background: #000;
        border-bottom: 1px solid var(--primary);
        position: absolute;
        right: 50px; /* Décale pour ne pas écraser le burger */
        top: 15px;
        z-index: 2005;
    }
    
    .search-icon {
        font-size: 1.2rem;
        padding: 10px;
        color: white;
    }
}