/* ==========================================================================
   CHARTE GRAPHIQUE CODE A-Z - MINIMALISTE DARK TECH (NOIR, BLANC, ROUGE)
   ========================================================================== */
:root {
    --bg-dark: #07070a;       /* Noir profond d'arrière-plan */
    --bg-card: #121216;       /* Gris sombre tech pour les cartes et conteneurs */
    --accent: #ff4757;        /* Rouge vif chirurgical pour les éléments d'action */
    --accent-hover: #ff2a3f;  /* Rouge survol */
    --text-main: #ffffff;     /* Blanc pur lisible */
    --text-muted: #9494a1;    /* Gris neutre pour les textes secondaires */
    --radius-sm: 8px;
    --radius-md: 16px;
    --transition-premium: 0.5s cubic-bezier(0.25, 1, 0.4, 1);
}

/* Reset Global & Typographie */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* ==========================================================================
   HEADER & BARRE DE RECHERCHE
   ========================================================================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 5%;
    background: rgba(7, 7, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.logo {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -1px;
    text-transform: uppercase;
}

.logo span { 
    color: var(--accent); 
    text-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

.search-container {
    position: relative;
    width: 35%;
}

.search-container i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
}

.search-container input {
    width: 100%;
    padding: 12px 20px 12px 48px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--bg-card);
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent);
    background: #16161c;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.15);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3.5rem 20px 2rem;
    background: radial-gradient(circle at top, rgba(255, 71, 87, 0.04) 0%, transparent 60%);
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
}

/* BARRE DE FILTRES */
.filters-container {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding: 1rem 5% 2rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.filters-container::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.02);
}

.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.35);
}

/* ==========================================================================
   GRILLE ET SYSTÈME DE SUBSTITUTION DE LA CARTE (HOVER PREMIUM)
   ========================================================================== */
.movie-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0 5% 4rem;
    width: 100%;
}

.movie-card {
    position: relative;
    background-color: var(--bg-card);
    border-radius: var(--radius-sm);
    height: 280px;
    overflow: hidden;
    cursor: pointer;
    
    /* Configuration Flexbox élastique pour le redimensionnement en ligne */
    width: 170px;
    flex-grow: 1;
    flex-shrink: 1;
    max-width: 210px;
    
    /* Animation fluide synchronisée */
    transition: flex-grow var(--transition-premium),
                max-width var(--transition-premium),
                transform 0.4s ease,
                box-shadow 0.4s ease;
}

/* Fixation des images structurelles */
.movie-card .poster-img,
.movie-card .backdrop-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* État initial : L'affiche verticale est visible, l'horizontale est invisible */
.movie-card .poster-img {
    z-index: 2;
    opacity: 1;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.4, 1);
}

.movie-card .backdrop-img {
    z-index: 1;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.4, 1);
}

/* L'overlay de contenu masqué initialement */
.movie-card .card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    opacity: 0;
    background: linear-gradient(180deg, rgba(7, 7, 10, 0.2) 0%, rgba(7, 7, 10, 0.95) 85%);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    transition: opacity 0.35s ease;
    pointer-events: none; /* S'active uniquement en hover */
}

/* --------------------------------------------------
   🔥 MÉCANIQUE INTERACTIVE : EXPANSION ET SUBSTITUTION
   ----------------------------------------------------- */
@media (min-width: 769px) {
    .movie-card:hover {
        flex-grow: 100;
        max-width: 380px; /* Devient un format cinéma large */
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
        transform: translateY(-4px);
    }

    /* Disparition de l'image verticale */
    .movie-card:hover .poster-img {
        opacity: 0;
    }

    /* Révélation de l'image horizontale */
    .movie-card:hover .backdrop-img {
        opacity: 1;
    }

    /* Affichage du texte et des boutons d'actions */
    .movie-card:hover .card-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Style interne du bloc de texte révélé */
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.card-year {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
    display: inline-block;
}

.card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

/* Boutons d'actions intégrés sur la carte */
.card-actions {
    display: flex;
    gap: 8px;
}

.card-actions button {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.card-actions .btn-play {
    background: var(--accent);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    gap: 6px;
}

.card-actions .btn-play:hover {
    background: var(--accent-hover);
    transform: scale(1.03);
}

.card-actions .btn-fav {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-actions .btn-fav:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.card-actions .btn-fav.active {
    background: rgba(255, 71, 87, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

/* ==========================================================================
   MODALES PREMIUM (APERÇU CINÉMATIQUE ET LECTEUR)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 4, 6, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.4, 1);
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    /* border-radius: var(--radius-md); */
    width: 100%;
    /* max-width: 1000px; */
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.4, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background: var(--accent);
    border-color: var(--accent);
}
.mute-toggle {
    right: 72px; /* se place à côté du bouton de fermeture (40px + marge) */
}
.personal-fullscreen-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 6; /* au-dessus de l'overlay (z-index: 5) */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.personal-fullscreen-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* Disposition immersive de la modale principale */
.cinematic-layout {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: #000;
}

.video-background-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

.video-background-wrapper iframe {
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scale(1.35); /* Supprime l'affichage natif parasite */
}

.video-dark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(7, 7, 10, 0.1) 0%, rgba(7, 7, 10, 0.8) 50%, #121216 100%);
    z-index: 2;
}

.cinematic-details {
    position: relative;
    z-index: 3;
    padding: 3.5rem 3rem;
    max-width: 750px;
}

.cinematic-details h2 {
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.1;
    text-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.tags {
    display: flex;
    gap: 8px;
}

.title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 18px;
}

.title-logo-wrap {
    height: 90px;
    width: 100%;
    max-width: 320px;
    display: flex;
    align-items: center;
}

.title-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left center;
}

.brand-logo-img {
    height: 60px;
    width: 60px;
    vertical-align: middle;
    margin-right: 4px;
}

.tag-accent {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(255, 71, 87, 0.15);
    color: var(--accent);
    border: 1px solid rgba(255, 71, 87, 0.2);
}

.synopsis {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

/* Grand Bouton d'action principal */
.play-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.3);
}

.play-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 71, 87, 0.45);
}

/* Interface de Lecture Finale Sécurisée */
.player-layout {
    max-width: 800px;
    background: #050508;
}

.secure-player-container {
    padding: 5rem 2rem;
    text-align: center;
    background: radial-gradient(circle at center, rgba(255, 71, 87, 0.04) 0%, transparent 75%);
}

.player-icon-glow {
    font-size: 3.5rem;
    color: var(--accent);
    margin-bottom: 16px;
    filter: drop-shadow(0 0 15px rgba(255, 71, 87, 0.5));
}

.secure-player-container h2 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.secure-player-container p {
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
    font-size: 0.95rem;
}

.loading-bar-ux {
    width: 180px;
    height: 4px;
    background: rgba(255,255,255,0.04);
    margin: 30px auto 0;
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-ux div {
    width: 40%;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    animation: loadingUX 1.6s infinite ease-in-out;
}
.player-message {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 8px;
}

.player-message-error {
    color: var(--accent);
    font-weight: 600;
    margin-top: 12px;
    display: none;
}

.player-message-error.visible {
    display: block;
}


@keyframes loadingUX {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

/* Loader d'API */
.loader {
    grid-column: 1 / -1;
    text-align: center;
    padding: 5rem 20px;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.loader i {
    animation: spin 1s linear infinite;
    margin-right: 10px;
    color: var(--accent);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.personal-player-wrapper {
    display: none;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.personal-player-wrapper.active {
    display: block;
}

.personal-player-wrapper iframe {
    width: 100%;
    height: 97%;
    border: 0;
    /* transform: scale(1.35);  */
    /* Supprime l'affichage natif parasite */
}
.personal-player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: pointer;
}

/* pointeur de recherche */
.seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0.85);
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 10px 16px;
    border-radius: 50px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 6;
}

.seek-indicator.left {
    left: 8%;
}

.seek-indicator.right {
    right: 8%;
}

.seek-indicator.visible {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Badge Disponible */
.badge-available {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;
    background: #1db954;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ==========================================================================
   VERSION RESPONSIVE MOBILE EXTRÊME (21e SIÈCLE ADAPTÉ)
   ========================================================================== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 12px;
        padding: 1rem 20px;
    }

    .search-container {
        width: 100%;
    }

    .hero {
        padding: 2rem 15px 1rem;
    }

    .hero h1 {
        font-size: 1.9rem;
    }

    .hero p {
        font-size: 0.95rem;
    }

    .filters-container {
        justify-content: flex-start;
        padding: 0.5rem 20px 1.5rem;
    }

    .filter-btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }

    /* Grille Mobile : Passage en 2 colonnes ultra-stables */
    .movie-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 16px 3rem;
    }

    .movie-card {
        width: 100%;
        max-width: none;
        height: 240px; /* Hauteur ajustée pour écran mobile */
    }

    /* Désactivation saine du hover d'élargissement sur écran tactile */
    .movie-card .poster-img {
        opacity: 1 !important;
        z-index: 2;
    }

    /* Remplacement par une info-bulle épurée et lisible en permanence au bas du poster */
    .movie-card .card-overlay {
        opacity: 1 !important;
        background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.9) 90%);
        padding: 8px;
    }

    .card-title {
        font-size: 0.85rem;
    }

    .card-year {
        font-size: 0.7rem;
        margin-bottom: 0;
    }

    .card-desc, 
    .card-actions {
        display: none !important; /* Nettoyage pour ne pas surcharger l'espace mobile tactile */
    }

    /* Modales adaptatives sur Mobile */
    .modal-content {
        width: 100%;
    }

    .cinematic-details {
        padding: 2rem 1.5rem;
    }

    .cinematic-details h2 {
        font-size: 1.8rem;
    }

    .synopsis {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    .play-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 24px;
    }
}

@media (max-width: 400px) {
    /* Optimisation pour très petits écrans */
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 8px 2rem;
    }
    
    .movie-card {
        height: 200px;
    }
}