/* --- STYLE SPÉCIFIQUE ADMIN --- */
body { background-color: #0a0a0a; overflow-x: hidden; }

/* Layout Grid */
.admin-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar (Liste des dossiers) */
.admin-sidebar {
    background: #111;
    border-right: 1px solid #333;
    display: flex; flex-direction: column;
}

.admin-header {
    padding: 20px; border-bottom: 1px solid #333;
    background: #000; text-align: center;
}
.admin-header h2 { font-family: 'Playfair Display', serif; color: #d4af37; margin: 0; }
.admin-header p { font-size: 0.8rem; color: #666; margin-top: 5px; }

.tabs-nav { 
    display: flex; 
    flex-wrap: wrap; /* NOUVEAU : Autorise le passage à la ligne */
    border-bottom: 1px solid #333; 
}
.tab-btn {
    flex: 1 1 50%; /* NOUVEAU : Force chaque bouton à prendre 50% de la largeur */
    background: transparent; border: none; color: #888;
    padding: 15px; cursor: pointer; transition: 0.3s;
    border-bottom: 2px solid transparent;
}
.tab-btn.active { color: #fff; border-bottom-color: #d4af37; background: #1a1a1a; }

.list-container { flex: 1; overflow-y: auto; padding: 0; }

.list-item {
    padding: 20px; border-bottom: 1px solid #222; cursor: pointer;
    transition: 0.2s; position: relative;
}
.list-item:hover { background: #1a1a1a; border-left: 3px solid #d4af37; }
.list-item.active { background: #222; border-left: 3px solid #d4af37; }

.item-title { color: #fff; font-weight: 600; margin-bottom: 5px; display: flex; justify-content: space-between; }
.item-subtitle { color: #888; font-size: 0.85rem; }
.badge-status { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; border: 1px solid #444; }

/* Main Content (Chat & Détails) */
.admin-main {
    display: flex; flex-direction: column;
    background: #0e0e0e;
    position: relative;
    width: 100%; /* S'assure qu'il prend toute la place */
    min-width: 0; /* Empêche le contenu de déborder du parent flex */
}

.main-header {
    padding: 20px; /* Réduit de 40px à 20px pour gagner de la place */
    border-bottom: 1px solid #333;
    display: flex; justify-content: space-between; align-items: flex-start; /* Aligné en haut */
    gap: 20px;
    background: #111;
    flex-wrap: wrap; /* Permet aux éléments de passer à la ligne sur petit écran */
}
.client-name { font-family: 'Playfair Display', serif; font-size: 1.5rem; color: #d4af37; }

/* Actions Bar */
.actions-bar {
    display: flex; gap: 15px; align-items: center;
}
.status-select {
    background: #000; color: #fff; border: 1px solid #444;
    padding: 8px 15px; border-radius: 4px; cursor: pointer;
}
.price-input {
    background: #000; color: #d4af37; border: 1px solid #444;
    padding: 8px 15px; width: 120px; text-align: right;
}

/* Chat Area */
.chat-viewport {
    flex: 1; overflow-y: auto; 
    padding: 20px; /* Réduit de 40px pour voir plus d'images */
    display: flex; flex-direction: column; gap: 20px;
}

/* --- AJOUT : Correction grille médiathèque --- */
.mediatheque-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); 
    gap: 15px;
    width: 100%;
    padding-bottom: 20px;
    flex-shrink: 0; /* ⬅️ LA LIGNE MAGIQUE : Empêche Flexbox d'écraser la grille */
}

/* Bulles (Inversées par rapport au client : Admin = Droite/Or) */
.msg-bubble { max-width: 70%; padding: 15px 20px; border-radius: 6px; font-size: 0.95rem; line-height: 1.5; }

.msg-admin { /* MOI (Admin) */
    align-self: flex-end; background: rgba(212, 175, 55, 0.2); 
    border: 1px solid rgba(212, 175, 55, 0.4); color: #fff;
}
.msg-client { /* CLIENT */
    align-self: flex-start; background: #222; border: 1px solid #333; color: #ccc;
}

/* Input Area */
.input-area {
    padding: 20px; background: #111; border-top: 1px solid #333;
    display: flex; gap: 15px;
}
.chat-input {
    flex: 1; background: #000; border: 1px solid #333; color: #fff;
    padding: 15px; border-radius: 4px; resize: none; outline: none;
}
.chat-input:focus { border-color: #d4af37; }

/* Loader Overlay */
#adminLoader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; z-index: 9999; display: flex; flex-direction: column;
    justify-content: center; align-items: center; color: #d4af37;
}

.hidden-desktop { display: none; }

/* --- AJOUT : Correction grille médiathèque --- */
.mediatheque-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
    gap: 15px;
    width: 100%;
    
    /* M2S : Rend la grille scrollable sans faire grandir toute la page */
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px; /* Évite que la barre de scroll ne touche les images */
}

/* M2S : Style de la photo quand on la maintient avec la souris */
.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed #d4af37;
    transform: scale(0.95);
    border-radius: 4px;
}


/* Responsive Mobile */
@media (max-width: 768px) {
    .admin-container { grid-template-columns: 1fr; }
    .admin-sidebar { height: 100vh; width: 100%; position: absolute; z-index: 100; transition: transform 0.3s; }
    .admin-sidebar.collapsed { transform: translateX(-100%); }
    .admin-main { height: 100vh; width: 100%; }
    .hidden-desktop { display: inline-block; }
    
    /* On s'assure que le fond reste opaque lors du slide */
    .admin-sidebar { 
        background: #111;
        box-shadow: 2px 0 15px rgba(0,0,0,0.8);
    }
}