/* === GLOBAL === */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* Maintenu pour le body global en dehors des media queries */
    height: 100%;
    font-family: Arial, sans-serif;
    background-color: #012326;
    color: #a8dadc;
    transform: translateZ(0); /* Utile pour la performance sur certaines animations */
}

.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* === HEADER SPLIT === */
.header { /* hauteur de la diapocategorie*/
    display: flex;
    flex-direction: column;
    height: 120px;
    flex-shrink: 0;
}

.header-top { /* marge au dessus de diapcat*/
    height: 0px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background-color: #012326;
}

.header-bottom {
    height: 120px;
    background-color: #01444b;
    display: flex;
    align-items: center;
    overflow-x: auto; /* Permet le défilement horizontal des catégories */
    padding: 0 10px;
    gap: 10px;
}


.header-top .logo {
    height: 40px;
}
.logo_ca {
    height: 40px;
}

.header-bottom img { /* taille image cat*/
    width: 120px;
    height: auto;
    border-radius: 10px;
    cursor: pointer;
    object-fit: cover;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.header-bottom img:hover {
    border-color: #a8dadc;
}

/* === MAIN STRUCTURE === */
.main {
    flex: 1; /* Permet au main de prendre l'espace restant verticalement */
    display: flex;
    flex-direction: row; /* Par défaut en mode bureau: liste à gauche, lecteur à droite */
    overflow: hidden;
    height: calc(100vh - 120px); /* Hauteur fixe pour le main en mode bureau */
    margin: 0;
}

.titre-categorie {
    font-size: 0.85em;
    font-weight: bold;
    padding: 5px;
    background: #01393d;
}

.liste {
    width: 300px;
    background: #01444b;
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin: 1;
}

/* #liste est l'UL/OL réel généré par JS, c'est lui qui doit scroller si besoin */
#liste {
    overflow-y: auto;    /* Défilement vertical pour la liste */
    flex-grow: 1;        /* Prend tout l'espace disponible à l'intérieur de #playlistWrapper */
    min-height: 0;       /* Correction pour les éléments flex avec overflow */
    overflow-x: hidden;  /* Empêche le défilement horizontal de la liste */
}

/* #playlistWrapper est le conteneur direct de #liste */
#playlistWrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.lecteur {
    flex-grow: 1; /* Le lecteur prend l'espace restant dans le main */
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%; /* Assure que .lecteur prend toute la hauteur disponible */
    box-sizing: border-box;
}

#videoWrapper {
    position: relative;
    width: 100%;
    max-width: 1920px;
    height: 100%;
    background: black;
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

video {
    width: 100%;
    height: 100%;
    background: black;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    display: block;
}

#posterImage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    z-index: 2;
    display: block;
    background-color: black;
}

.item {
    padding: 10px;
    margin-bottom: 10px;
    background: #025860;
    border-radius: 6px;
    cursor: pointer;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item:hover {
    background: #03777d;
}

#recherche {
    width: 90%;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: none;
}

.sous-texte {
    font-size: 0.7em;
    opacity: 0.85;
    display: block;
    margin-top: 2px;
    line-height: 1.2em;
}

.fade-out {
    transition: opacity 2s ease;
    opacity: 0;
}

#video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}


#index-alpha-list {
    background-color: #111;
    color: #eee;
    padding: 1rem;
    max-height: 100%;
    overflow-y: auto;
    font-family: sans-serif;
}

#index-alpha-list h2 {
    font-size: 1.2rem;
    color: #0ff;
    margin-bottom: 1rem;
}

.index-entry {
    margin: 0.5rem 0;
    cursor: pointer;
    padding: 0.5rem;
    border-bottom: 1px solid #333;
}

.index-entry:hover {
    background-color: #222;
}

.index-title {
    font-weight: bold;
    font-size: 1.1rem;
}

.index-mention {
    font-size: 0.85rem;
    color: #aaa;
}
#index-alpha-list {
    height: 100%;
    max-height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-sizing: border-box;
}


/* --- STYLES POUR LE PLEIN ÉCRAN --- */

/* Masque UNIQUEMENT le bouton plein écran natif pour forcer l'utilisation du nôtre */
video::-webkit-media-controls-fullscreen-button {
    display: none !important;
}
video::-moz-full-screen-button { /* Pour Firefox */
     display: none !important;
}

/* Styles pour le bouton plein écran personnalisé */
#fullscreenButton {
    position: absolute;
    bottom: 20px;
    right: 25px;
    background-color: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
    z-index: 10;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fullscreenButton:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

#fullscreenButton svg {
    display: block;
}

/* *** MODIFICATIONS CLÉS ICI POUR L'ARTEFACT ET LE PLEIN ÉCRAN *** */

/* Assurez-vous que HTML et BODY ont un fond noir et pas de marges/paddings en plein écran */
html:-webkit-full-screen, html:-moz-full-screen, html:-ms-fullscreen, html:fullscreen,
body:-webkit-full-screen, body:-moz-full-screen, body:fullscreen {
    margin: 0 !important;
    padding: 0 !important;
    background-color: black !important;
    overflow: hidden !important;
}

/* Style de #videoWrapper lorsqu'il est en plein écran */
#videoWrapper:-webkit-full-screen,
#videoWrapper:-moz-full-screen,
#videoWrapper:-ms-fullscreen,
#videoWrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    aspect-ratio: auto !important;
    background-color: black !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 2147483647 !important;
}


/* Assurez-vous que le conteneur interne et la vidéo s'adaptent, en conservant le ratio */
#videoWrapper:fullscreen #video-container,
#videoWrapper:fullscreen video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    position: static !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: black !important;
    display: block !important;
}

/* La bannière mécène en plein écran */
#videoWrapper:fullscreen .mecene-screen {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    position: static !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: black !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Le slogan/image d'attente en plein écran */
#videoWrapper:fullscreen #posterImage {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    position: static !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: black !important;
}

/* === MEDIA QUERIES === */
@media screen and (max-width: 1000px) {
    html, body {
        overflow: auto; /* Permet le défilement général si besoin sur les petits écrans */
    }
}

@media screen and (max-width: 1000px) and (orientation: portrait) {
    .main {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 120px);
        overflow-y: auto; /* MODIFIÉ: Permet le défilement vertical du contenu principal si nécessaire */
        overflow-x: hidden; /* Empêche le défilement horizontal indésirable */
    }

    .lecteur {
        width: 100%;
        order: 1;
        /* MODIFIÉ: Le lecteur prend une part définie (ici 60%) de l'espace vertical disponible dans le main */
        flex: 0 0 40%; /* Pas de croissance, pas de rétrécissement, prend 60% de la hauteur de son parent main */
        /* MODIFIÉ: Assurer une hauteur explicite qui peut être compressée si l'espace est très limité, mais l'objectif est de 60% */
        height: 60%; /* Laisser à 60% ou supprimer si flex-basis est suffisant. Flex-basis est plus fort. */
        box-sizing: border-box;
    }

    .liste {
        width: 100%;
        order: 2;
        padding: 10px;
        display: flex;
        flex-direction: column;
        flex-grow: 1; /* MODIFIÉ: La liste prend tout l'espace vertical restant */
        flex-basis: 0%; /* Commence avec une base de 0 pour permettre à flex-grow de fonctionner */
        min-height: 0;
        box-sizing: border-box;
    }

    /* Ces règles existent déjà et sont bonnes */
    #playlistWrapper {
        flex-grow: 1;
        min-height: 0;
    }

    #liste {
        overflow-y: auto;
        overflow-x: hidden;
        flex-grow: 1;
        min-height: 0;
    }

    .zone-index {
        font-size: 2em;
        padding: 1em;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .zone-index button {
        margin: 0.4em;
        width: 3em;
        height: 3em;
        font-size: 1.5em;
    }
}

@media screen and (max-width: 1000px) and (orientation: landscape) {
    .main {
        flex-direction: row;
        height: auto;
        overflow: visible; /* Ou auto si le contenu peut déborder */
    }

    .liste {
        width: 320px;
        flex-shrink: 0;
        min-height: 0;
        overflow-y: auto;
    }

    #playlistWrapper {
        max-height: 60vh; /* Peut-être ajuster si la liste est trop courte ou trop longue */
        overflow: hidden; /* Garder hidden si la liste doit scroller via #liste */
    }

    #liste {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .lecteur {
        flex-grow: 1;
        flex-shrink: 0;
        min-height: 0;
        height: 100%;
    }

    #videoWrapper {
        width: 100%;
        height: 100%;
    }

    @media screen and (max-width: 600px) {
        .img-mecene {
            width: 90%;
        }
    }

    @media screen and (min-width: 601px) and (max-width: 1000px) {
        .img-mecene {
            width: 75%;
        }
    }

    @media screen and (min-width: 1001px) {
        .img-mecene {
            width: 60%;
        }
    }
}