/* --- VARIABLES & COULEURS --- */
:root { 
    --bg: #121212; 
    --card: #1e1e1e; 
    --pastel-blue: #A7C7E7;
    --text: #ffffff; 
    --danger: #ff4757;
    --border: rgba(255, 255, 255, 0.08);
}

/* --- RESET & STRUCTURE GLOBALE --- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body { 
    background: var(--bg); color: var(--text); 
    font-family: 'Segoe UI', Roboto, sans-serif; 
    padding: 20px; display: flex; flex-direction: column; min-height: 100vh;
}

img { max-width: 100%; height: auto; }

.container-fiche { 
    width: 100%; max-width: 1100px; margin: 0 auto;
    flex: 1 0 auto; display: flex; flex-direction: column;
}

/* --- HEADER & NAV --- */
.user-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.avatar { width: 45px; height: 45px; border-radius: 50%; border: 2px solid var(--pastel-blue); object-fit: cover; }
.tabs { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 1px solid var(--border); padding-bottom: 15px; overflow-x: auto; }
.tab-btn { background: #252525; border: 1px solid #444; color: #888; padding: 10px 18px; border-radius: 6px; font-weight: 800; transition: 0.3s; font-size: 0.75em; text-decoration: none; text-transform: uppercase; }
.tab-btn.active { background: var(--pastel-blue); color: #121212; border-color: var(--pastel-blue); }

/* --- BOUTONS & INPUTS --- */
input { padding: 12px; border-radius: 8px; border: 1px solid #333; background: #1a1a1a; color: white; outline: none; width: 100%; }
.btn-interact, .btn-open-rate, .btn-save-rate {
    background: var(--pastel-blue); color: #121212; padding: 12px 20px;
    border: none; border-radius: 8px; font-weight: 800; cursor: pointer;
    text-transform: uppercase; font-size: 0.75em; width: 100%; transition: 0.3s;
}
.btn-interact:hover { opacity: 0.9; transform: scale(0.98); }

/* --- GRILLES (Films & Collection) --- */
.movie-grid { 
    display: grid !important; 
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; 
    gap: 25px !important; width: 100% !important; margin-top: 20px;
}
.movie-card { text-decoration: none; transition: transform 0.3s ease; display: flex; flex-direction: column; }
.movie-card:hover { transform: translateY(-8px); }
.poster-box { aspect-ratio: 2/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.movie-poster { width: 100%; height: 100%; object-fit: cover; }
.movie-title { margin: 12px 0 4px 0; font-size: 0.9em; font-weight: 700; color: #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- FICHE TECHNIQUE --- */
.fiche-layout { display: flex; gap: 40px; margin-top: 30px; align-items: flex-start; }
.side-col { width: 350px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.info-col { flex: 1; min-width: 0; }
.movie-full-title { font-size: 3.5em; margin: 0 0 15px 0; line-height: 1; letter-spacing: -2px; }
.director-tag { color: var(--pastel-blue); font-weight: 800; text-transform: uppercase; font-size: 0.85em; display: block; margin-bottom: 5px; }
.fiche-poster { width: 100%; max-width: 350px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: block; }
.genre-container { display: flex; gap: 8px; margin: 15px 0; flex-wrap: wrap; }
.genre-badge { background: rgba(167, 199, 231, 0.1); color: var(--pastel-blue); padding: 5px 12px; border-radius: 6px; font-size: 0.75em; font-weight: 700; border: 1px solid rgba(167, 199, 231, 0.2); }
.synopsis-text { line-height: 1.7; color: #bbb; margin-top: 10px; }
.chart-aside-float { float: right; width: 280px; margin-left: 30px; margin-bottom: 20px; background: rgba(255, 255, 255, 0.02); border-radius: 15px; padding: 20px; border: 1px solid var(--border); text-align: center; }

/* Widget Dispo */
.providers-box { width: 100%; max-width: 350px; margin-top: 30px; text-align: center; }
.providers-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; background: rgba(255,255,255,0.02); padding: 15px; border-radius: 12px; border: 1px solid var(--border); }
.provider-logo { width: 32px; height: 32px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.05); }

/* Distribution Acteurs */
.cast-section { clear: both; margin-top: 40px; padding-top: 25px; border-top: 1px solid var(--border); }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 20px; margin-top: 20px; }
.actor-card { text-align: center; }
.actor-card img { width: 70px; height: 70px; object-fit: cover; border-radius: 50%; border: 2px solid var(--border); margin-bottom: 8px; }
.actor-name { font-size: 0.75em; font-weight: 800; display: block; color: #eee; }
.actor-role { font-size: 0.65em; color: #555; }

/* --- PAGE ROOMS (ARCHITECTURE GRID STRICTE) --- */
.rooms-section-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-areas: 
        "header header"
        "list sidebar";
    gap: 30px 40px; /* 30px sous le titre, 40px entre les colonnes */
    margin-top: 40px;
    width: 100%;
    align-items: flex-start; /* GARANTIT QUE GAUCHE ET DROITE SONT ALIGNÉS EN HAUT */
}

.rooms-header-full { grid-area: header; }
.rooms-header-full h2 { margin: 0; line-height: 1; }

.rooms-list-area { grid-area: list; display: flex; flex-direction: column; margin: 0; }
.rooms-stack { display: flex; flex-direction: column; gap: 20px; }

/* On a tué le margin-top fantôme ici */
.sidebar-actions { grid-area: sidebar; display: flex; flex-direction: column; gap: 20px; margin: 0; }

.room-card-large { 
    background: rgba(255,255,255,0.02); border: 1px solid var(--border); 
    padding: 25px; border-radius: 15px; 
    display: flex; justify-content: space-between; align-items: center; 
    text-decoration: none; color: inherit; transition: 0.3s; 
}
.room-card-large:hover { border-color: var(--pastel-blue); }
.room-main h4 { margin: 0; font-size: 1.3em; letter-spacing: -0.5px; }
.room-meta-info { display: flex; gap: 15px; margin-top: 8px; font-size: 0.8em; color: #555; }
.room-meta-info .code-span { color: var(--pastel-blue); font-family: monospace; }
.arrow-icon { font-size: 1.5em; color: var(--pastel-blue); opacity: 0.3; transition: 0.3s; }
.room-card-large:hover .arrow-icon { opacity: 1; transform: translateX(5px); }

.action-box { background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border); border-radius: 15px; padding: 20px; height: fit-content; }
.action-box h3 { font-size: 0.65em; letter-spacing: 2px; color: var(--pastel-blue); margin-bottom: 15px; text-transform: uppercase; font-weight: 800; }
.room-input { background: #000 !important; border: 1px solid #222 !important; margin-bottom: 12px; }

/* --- MODALE SCROLLABLE --- */
.modal-rate {
    display: none; position: fixed; z-index: 9999;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); backdrop-filter: blur(8px);
    overflow-y: auto; padding: 40px 0;
}
.modal-rate-content {
    background: var(--card); margin: auto; padding: 30px 40px;
    width: 90%; max-width: 600px; border-radius: 20px; border: 1px solid var(--border);
    position: relative;
}
.close-modal { position: absolute; right: 25px; top: 20px; font-size: 40px; line-height: 1; cursor: pointer; color: #555; transition: 0.3s; }
.close-modal:hover { color: var(--pastel-blue); transform: scale(1.1); }

/* SLIDERS */
.rate-item { margin-bottom: 18px; }
.rate-header { margin-bottom: 4px; }
.rate-header label { font-size: 0.7em; font-weight: 900; color: #555; text-transform: uppercase; letter-spacing: 1px; }
.slider-container { position: relative; padding: 0 5px; }
.rate-slider {
    -webkit-appearance: none; width: 100%; height: 6px; background: #222; border-radius: 3px; outline: none;
    background-image: linear-gradient(to right, #333 1px, transparent 1px); background-size: 10% 100%;
}
.rate-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px;
    background: #555; border-radius: 50%; cursor: pointer;
    opacity: 0.5; transition: 0.3s; border: 2px solid #121212;
}
.rate-slider.active::-webkit-slider-thumb {
    background: var(--pastel-blue); opacity: 1;
    box-shadow: 0 0 10px rgba(167, 199, 231, 0.4);
}
.slider-labels-row { display: flex; justify-content: space-between; margin-top: 2px; }
.slider-label { font-size: 0.6em; color: #444; font-weight: 700; text-transform: uppercase; }
.btn-save-rate { margin-top: 10px !important; }

/* --- FOOTER --- */
footer {
    flex-shrink: 0; margin-top: auto; padding: 30px 0; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; font-size: 0.75em; color: #444; font-weight: 700; width: 100%;
}
/* =========================================
   PAGE ROOM (Détail d'une session)
   ========================================= */

/* Header spécifique à la room */
.page-room .room-top-header { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 15px 0; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.page-room .room-title-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.page-room .room-meta-row { display: flex; gap: 20px; color: #888; font-size: 0.85em; font-weight: bold; }

/* Bouton Détruire */
.page-room .btn-destroy { background: transparent !important; border: 1px solid var(--danger) !important; color: var(--danger) !important; }
.page-room .btn-destroy:hover { background: rgba(255, 71, 87, 0.1) !important; }

/* Bouton Flamme (Vote) */
.page-room .btn-fire { background: none; border: none; font-size: 1.2em; cursor: pointer; transition: 0.2s; filter: grayscale(1); opacity: 0.3; padding: 0; }
.page-room .btn-fire.active { filter: grayscale(0); opacity: 1; transform: scale(1.2); }
.page-room .btn-fire:hover { transform: scale(1.1); opacity: 0.8; }

/* Badges en overlay sur le poster */
.page-room .poster-box-relative { position: relative; display: block; width: 100%; }
.page-room .badges-overlay { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 20; }
.page-room .badge-round { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75em; background: var(--bg); border: 1px solid var(--border); box-shadow: 0 4px 8px rgba(0,0,0,0.8); }
.page-room .badge-seen { color: var(--pastel-blue); font-weight: 900; }
.page-room .badge-liked { color: var(--danger); }

/* Modale de Recherche (Spécifique à la room) */
.page-room .modal-search { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); backdrop-filter: blur(8px); overflow-y: auto; padding: 40px 0; }
.page-room .modal-search-content { background: var(--card); margin: auto; padding: 40px; width: 90%; max-width: 600px; border-radius: 20px; border: 1px solid var(--border); position: relative; }
.page-room #roomSearchInput { width: 100%; padding: 15px; background: #000; border: 1px solid var(--border); color: #fff; border-radius: 10px; font-size: 1em; margin-bottom: 20px; outline: none; }
.page-room #roomSearchInput:focus { border-color: var(--pastel-blue); }
.page-room .search-results-room { max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.page-room .res-item { display: flex; gap: 15px; padding: 10px; border: 1px solid transparent; cursor: pointer; align-items: center; border-radius: 8px; transition: 0.2s; background: rgba(255,255,255,0.02); }
.page-room .res-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(167, 199, 231, 0.3); }
.page-room .res-item img { width: 45px; height: 65px; object-fit: cover; border-radius: 6px; }
.page-room .close-modal-search { position: absolute; right: 25px; top: 20px; font-size: 40px; line-height: 1; cursor: pointer; color: #555; transition: 0.3s; }
.page-room .close-modal-search:hover { color: var(--pastel-blue); transform: scale(1.1); }
/* =========================================
   PAGE USER (Profil)
   ========================================= */

/* Grille Haut : Profil & Chart */
.page-user .user-top-grid {
    display: grid;
    grid-template-columns: 1fr 350px; /* Colonne gauche fluide, colonne droite fixe pour la chart */
    gap: 40px;
    margin-top: 30px;
    align-items: center; /* Centre verticalement le profil et la chart */
}

.page-user .user-profile-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.page-user .user-name-title { margin: 0 0 15px 0; font-size: 2.2em; letter-spacing: -1px; }
.page-user .user-large-avatar { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 2px solid var(--pastel-blue); box-shadow: 0 10px 20px rgba(0,0,0,0.5); }

.page-user .adn-label { font-size: 0.9em; letter-spacing: 1px; color: #777; font-weight: 400; cursor: help; position: relative; display: inline-block; margin: 20px 0 30px 0; }
.page-user .adn-type { color: var(--pastel-blue); font-weight: 700; text-transform: lowercase; }
.page-user .adn-label:after { content: attr(data-tooltip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%) translateY(10px); width: 220px; padding: 10px; background: #1a1a1a; color: #eee; font-size: 11px; line-height: 1.4; text-align: center; border-radius: 8px; border: 1px solid var(--pastel-blue); box-shadow: 0 10px 20px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: all 0.15s ease-out; z-index: 100; }
.page-user .adn-label:hover:after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Blocs Stats (Vus / Likés) Cliquables */
.page-user .stats-header-row { display: flex; gap: 20px; width: 100%; max-width: 400px; margin: 0 auto; }
.page-user .counter-box-link { flex: 1; background: rgba(255,255,255,0.02); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); text-align: center; text-decoration: none; transition: 0.3s; display: flex; flex-direction: column; justify-content: center; }
.page-user .counter-box-link:hover { background: rgba(255,255,255,0.05); border-color: var(--pastel-blue); transform: translateY(-3px); }
.page-user .counter-box-link span { font-size: 1.8em; font-weight: 900; color: var(--pastel-blue); line-height: 1.2; }
.page-user .counter-box-link label { font-size: 0.6em; letter-spacing: 1px; color: #555; font-weight: bold; cursor: pointer; }

/* Bloc Chart */
.page-user .chart-main-card { background: rgba(255,255,255,0.02); padding: 20px; border-radius: 12px; border: 1px solid var(--border); box-sizing: border-box; }
.page-user .user-chart-container { position: relative; height: 300px; width: 100%; display: flex; justify-content: center; align-items: center; }

/* Grille Bas : Rooms & Agenda */
.page-user .user-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 320px; /* Même dimension que sidebar rooms.php pour cohérence */
    gap: 40px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
    align-items: flex-start;
}

.page-user .section-title-sm { font-size: 0.7em; letter-spacing: 2px; color: #444; margin-bottom: 20px; text-transform: uppercase; font-weight: 800; }

.page-user .agenda-placeholder { background: rgba(255,255,255,0.01); border: 1px dashed #333; border-radius: 15px; padding: 40px 20px; text-align: center; }
        .controls-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .filter-nav { 
            display: flex; gap: 20px; margin-bottom: 0; /* Margin retiré car géré par le conteneur */
        }

        .search-input {
            background: #0a0a0a;
            border: 1px solid #222;
            color: #eee;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 0.8em;
            font-family: inherit;
            outline: none;
            transition: border-color 0.3s ease;
            width: 200px;
        }
        .search-input:focus { border-color: var(--pastel-blue); }

        /* ==========================================================================
   PAGE COLLECTION
   ========================================================================== */

/* Structure de base pour forcer le footer en bas */
body.page-collection {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.page-collection .container-fiche {
    flex: 1; /* Pousse le footer vers le bas */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* En-tête */
.page-collection .collection-header { 
    margin: 40px 0 20px 0; 
    border-bottom: 1px solid #111; 
    padding-bottom: 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: baseline; 
}

.page-collection .collection-header h1 { 
    font-size: 2em; 
    letter-spacing: -1px; 
    margin: 0; 
}

.page-collection .collection-header span { 
    color: var(--pastel-blue); 
    font-weight: 800; 
    font-size: 0.8em; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

/* Barre de recherche */
.page-collection .search-wrapper { 
    width: 100%; 
    margin-bottom: 30px; 
}

.page-collection .search-input {
    width: 100%;
    background: #0a0a0a;
    border: 1px solid #222;
    color: #eee;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 0.9em;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.page-collection .search-input:focus { 
    border-color: var(--pastel-blue); 
    background: #111; 
}

/* Navigation et filtres */
.page-collection .filter-nav { 
    display: flex; 
    gap: 20px; 
    margin-bottom: 30px; 
}

.page-collection .filter-link { 
    text-decoration: none; 
    color: #444; 
    font-size: 0.75em; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    padding-bottom: 5px; 
    border-bottom: 2px solid transparent;
}

.page-collection .filter-link.active { 
    color: var(--pastel-blue); 
    border-color: var(--pastel-blue); 
}

/* Grille de films */
.page-collection .movie-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
    gap: 25px; 
    margin-bottom: 50px;
}

/* Éléments de la grille */
.page-collection .movie-item { 
    text-decoration: none; 
    transition: transform 0.3s ease; 
    position: relative; 
    display: block;
}

.page-collection .movie-item:hover { 
    transform: translateY(-10px); 
}

.page-collection .poster-wrapper {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
    background: #0a0a0a;
}

.page-collection .movie-poster { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

.page-collection .movie-item h4 { 
    margin: 12px 0 4px 0; 
    font-size: 0.9em; 
    color: #eee; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.page-collection .movie-item p { 
    margin: 0; 
    font-size: 0.75em; 
    color: #555; 
    font-weight: 600; 
}

/* Badge de score */
.page-collection .score-badge {
    position: absolute; 
    top: 10px; 
    right: 10px;
    background: var(--pastel-blue); 
    color: #000;
    padding: 4px 8px; 
    border-radius: 4px;
    font-size: 0.7em; 
    font-weight: 900;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE)
   ========================================================================== */

@media (max-width: 768px) {
    /* 1. Ajustement des conteneurs principaux */
    .container-fiche {
        padding: 0 15px; /* On réduit un peu les marges sur les côtés */
    }

    /* 2. La Room : On passe de 2 colonnes à 1 seule */
    .rooms-section-grid {
        display: flex;
        flex-direction: column; /* Empile la liste des films et la sidebar */
        gap: 30px;
    }

    /* 3. On remonte la sidebar ou on change son ordre si besoin */
    .sidebar-actions {
        order: 2; /* Les membres passent sous la liste des films */
        width: 100%;
    }

    .rooms-list-area {
        order: 1;
        width: 100%;
    }

    /* 4. Grille de films : on force 2 colonnes au lieu de 4 ou 5 */
    .movie-grid {
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 15px !important;
    }

    /* 5. Titres et en-têtes */
    .room-title-row {
        flex-direction: column; /* Le titre au-dessus du bouton détruire */
        align-items: flex-start !important;
        gap: 15px;
    }

    .room-title-row h1 {
        font-size: 1.8em !important; /* On réduit la taille du texte */
    }

    /* 6. Header du site (le logo et profil) */
    header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    /* 7. Navigation (le menu) */
    nav {
        overflow-x: auto; /* Permet de scroller le menu horizontalement s'il est trop large */
        white-space: nowrap;
        padding-bottom: 5px;
    }
}
