/* =========================================
   SILENCIO - ADMIN STYLES (V2)
   ========================================= */
:root {
    --color-bg: #050505;
    --color-panel: #111111;
    --color-text: #ffffff;
    --color-text-muted: #888888;
    --color-accent: #D72725;
    --color-accent-hover: #b31d1b;
    --color-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Montserrat', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-main);
    display: block !important; /* Force le mode normal, annule l'ancien flex */
    min-height: 100vh;
}

/* --- LAYOUT PRINCIPAL --- */
.admin-layout { 
    display: flex; 
    width: 100%; 
    min-height: 100vh; 
}

.admin-sidebar {
    width: 250px;
    background-color: var(--color-panel);
    border-right: 1px solid var(--color-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.admin-logo {
    font-size: 1.5rem; font-weight: 200; letter-spacing: 2px; margin-bottom: 3rem;
}
.admin-logo span { color: var(--color-accent); font-weight: 600; font-size: 0.8rem; vertical-align: top; }

.admin-sidebar nav { display: flex; flex-direction: column; gap: 1rem; flex-grow: 1; }
.admin-sidebar nav a {
    color: var(--color-text-muted); text-decoration: none; font-size: 0.9rem;
    text-transform: uppercase; letter-spacing: 1px; transition: color 0.3s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color: var(--color-text); }
.admin-sidebar nav a.active { border-left: 2px solid var(--color-accent); padding-left: 10px; }

.sidebar-footer {
    margin-top: auto; 
    padding-top: 2rem;
}

.admin-content { flex-grow: 1; padding: 3rem; overflow-y: auto; }

.content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3rem; }
.content-header h1 { font-weight: 200; letter-spacing: 2px; font-size: 2rem; }

/* --- BOUTONS --- */
button { cursor: pointer; font-family: inherit; border: none; border-radius: 4px; transition: all 0.3s; }
.btn-primary { background: var(--color-accent); color: #fff; padding: 10px 20px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; font-size: 0.8rem; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); padding: 10px 20px; }
.btn-secondary:hover { background: rgba(255,255,255,0.05); }

/* --- PANNEAUX & GRILLE --- */
/* --- PANNEAUX & GRILLE --- */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: 1fr; /* LA CORRECTION : 1 seule colonne qui prend 100% de la place */
    gap: 2rem; 
    align-items: start; 
    width: 100%;
}
.panel { 
    background: var(--color-panel); 
    border: 1px solid var(--color-border); 
    border-radius: 8px; 
    padding: 2rem; 
    width: 100%; /* Force le panneau à s'étirer */
}
.panel h2 { font-weight: 400; margin-bottom: 0.5rem; font-size: 1.2rem; }
.help-text { color: var(--color-text-muted); font-size: 0.8rem; margin-bottom: 2rem; }

/* --- LISTE SORTABLE --- */
.sortable-list { list-style: none; }
.sortable-item {
    display: flex; align-items: center; background: var(--color-bg); border: 1px solid var(--color-border);
    padding: 10px; margin-bottom: 10px; border-radius: 6px; transition: border-color 0.2s;
}
.sortable-item:hover { border-color: var(--color-accent); }
.drag-handle { cursor: grab; padding: 0 15px; color: var(--color-text-muted); font-size: 1.2rem; }
.drag-handle:active { cursor: grabbing; }
.item-thumb { width: 50px; height: 50px; object-fit: cover; border-radius: 4px; margin-right: 15px; }
.item-info { flex-grow: 1; display: flex; flex-direction: column; }
.item-info strong { font-weight: 400; font-size: 1rem; }
.item-info span { font-size: 0.75rem; color: var(--color-accent); text-transform: uppercase; letter-spacing: 1px; }
.item-actions { display: flex; gap: 10px; }
.btn-icon { background: transparent; color: var(--color-text-muted); font-size: 1.2rem; }
.btn-icon:hover { color: var(--color-text); }
.btn-icon.delete:hover { color: var(--color-accent); }

/* --- FORMULAIRES --- */
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--color-text-muted); }
input[type="text"], input[type="url"], input[type="email"], input[type="password"] {
    width: 100%; padding: 12px; background: var(--color-bg); border: 1px solid var(--color-border);
    color: var(--color-text); border-radius: 4px; font-family: inherit;
}
input:focus { outline: none; border-color: var(--color-accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; }

/* --- DROPZONE --- */
.dropzone {
    border: 2px dashed var(--color-border); 
    border-radius: 8px; 
    padding: 2rem; 
    text-align: center;
    cursor: pointer; 
    transition: all 0.3s; 
    position: relative; 
    min-height: 200px; /* Hauteur fixe pour que le cadre soit toujours beau */
    display: flex; 
    justify-content: center; 
    align-items: center;
    overflow: hidden; /* C'EST LA CLÉ : empêche l'image de déborder */
    background: var(--color-bg);
}

.dropzone:hover, .dropzone.dragover { 
    border-color: var(--color-accent); 
    background: rgba(215, 39, 37, 0.05); 
}

.dropzone img { 
    position: absolute;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    object-fit: contain; /* L'image rentre en entier sans être coupée ni déformée */
    padding: 15px; /* Laisse un espace élégant entre l'image et les pointillés */
    z-index: 1;
    pointer-events: none; /* Permet de cliquer/glisser à travers l'image */
}

.dropzone img.hidden { 
    display: none; 
}

.drop-text {
    position: relative;
    z-index: 2;
}

/* --- TOAST NOTIFICATION --- */
.toast {
    position: fixed; bottom: 30px; right: 30px; background: #222; color: #fff;
    padding: 15px 25px; border-left: 4px solid var(--color-accent); border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); z-index: 1000;
}

/* --- LOGIN OVERLAY --- */
.login-overlay {
    position: fixed !important; 
    top: 0; left: 0; 
    width: 100vw; height: 100vh;
    background: var(--color-bg); 
    z-index: 999999 !important; /* Force le passage au premier plan */
    display: flex; justify-content: center; align-items: center;
}
.login-box {
    background: var(--color-panel); padding: 3rem; border-radius: 8px;
    border: 1px solid var(--color-border); text-align: center; 
    width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}
.login-box h2 { font-weight: 200; letter-spacing: 2px; margin-bottom: 2rem; font-size: 1.8rem; }
.login-box h2 span { color: var(--color-accent); font-weight: 600; font-size: 0.8rem; vertical-align: top; }
.error-text { color: #ff0000; font-size: 0.8rem; margin-top: 1rem; }

.back-link-login {
    color: var(--color-text-muted); font-size: 0.85rem; text-decoration: none;
    transition: color 0.3s ease; text-transform: uppercase; letter-spacing: 1px;
}
.back-link-login:hover { color: var(--color-text); }

/* --- UTILITAIRES (LA CLASSE MAGIQUE) --- */
.hidden { 
    display: none !important; 
}

/* --- ÉTAT DRAG & DROP --- */
.sortable-item.dragging {
    opacity: 0.6;
    background: rgba(215, 39, 37, 0.1);
    border-style: dashed;
    border-color: var(--color-accent);
}

/* =========================================================
   RESPONSIVE ADMIN (MOBILE & TABLETTE)
   ========================================================= */
@media (max-width: 1024px) {
    
    /* 1. On passe le layout en colonne (la sidebar passe en haut) */
    .admin-layout { 
        flex-direction: column; 
    }

    /* 2. On transforme la Sidebar en En-tête */
    .admin-sidebar { 
        width: 100%; 
        padding: 1.5rem; 
        border-right: none; 
        border-bottom: 1px solid var(--color-border);
    }
    
    .admin-logo { 
        margin-bottom: 0; 
        text-align: center;
    }

    .admin-sidebar nav { 
        flex-direction: row; 
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
        margin: 1.5rem 0;
    }
    
    .admin-sidebar nav a {
        font-size: 0.8rem;
    }

    /* 3. Les boutons d'action s'alignent côte à côte */
    .sidebar-footer { 
        display: flex; 
        flex-direction: row; 
        gap: 10px; 
        padding-top: 0; 
        margin-top: 0;
    }
    .sidebar-footer a, .sidebar-footer button { 
        margin-bottom: 0 !important; 
        width: auto !important; 
        flex: 1; /* Ils prennent chacun 50% de la largeur */
    }

    /* 4. On adapte le contenu principal */
    .admin-content { 
        padding: 1.5rem; 
    }
    
    .content-header { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 15px; 
        margin-bottom: 2rem; 
    }
    
    .content-header h1 { 
        font-size: 1.5rem; 
    }

    /* 5. On empile la liste et le formulaire */
    .dashboard-grid { 
        grid-template-columns: 1fr; 
        gap: 2rem;
    }

    /* 6. On évite que la boîte de login ne touche les bords de l'écran */
    .login-box { 
        margin: 1.5rem; 
        padding: 2rem; 
    }
}

/* Petite optimisation pour les très petits écrans (iPhone SE etc.) */
@media (max-width: 480px) {
    .sortable-item {
        flex-wrap: wrap;
    }
    .item-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 10px;
    }
}

/* =========================================
   DIRECTION ARTISTIQUE : VISUALISATION BENTO (D.A.)
   ========================================= */

/* Par défaut, la prévisualisation est un Carré Standard */
#image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1); /* Animation fluide */
    margin: 1rem auto;
    
    /* On cloue les formes manuellement pour l'aperçu */
    aspect-ratio: 1 / 1; 
    max-width: 300px;
}

/* --- Quand on sélectionne "Standard" --- */
#image-preview.preview-standard {
    aspect-ratio: 1 / 1;
    max-width: 300px;
}

/* --- Quand on sélectionne "Grand Panoramique" --- */
#image-preview.preview-big {
    aspect-ratio: 1 / 1;
    max-width: 100%; /* S'étend pour simuler le Grand Format */
}

/* --- Quand on sélectionne "Vertical Affiche" --- */
#image-preview.preview-tall {
    aspect-ratio: 1 / 2; /* Format Portrait Cinéma */
    max-width: 250px; /* Plus étroit */
}

/* =========================================
   SILENCIO D.A. CONSTRUCTOR (DIVISION ANIMÉE V2)
   ========================================= */

#image-da-container {
    width: 100%;
    border-radius: 8px;
    background: #000000;
    border: 1px dashed rgba(255,255,255,0.3);
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    min-height: 180px;
}

#image-da-container:hover { border-color: var(--color-accent); }

/* --- Écrase le style de base de la dropzone pour l'intégrer proprement --- */
#image-da-container .dropzone {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
}

/* --- ÉTAT 1 : Zone de dépôt seule --- */
#image-da-container.da-container-single { aspect-ratio: 21 / 9; }
#image-da-container.da-container-single .drop-text {
    color: #fff; text-align: center; pointer-events: none;
}

/* --- ÉTAT 2 : Divisé en 2 (avec image) --- */
#image-da-container.da-container-split {
    aspect-ratio: auto;
    border-style: solid; /* La bordure devient continue */
}

/* On cache le texte, mais la zone invisible reste cliquable par dessus ! */
#image-da-container.da-container-split .drop-text { display: none; }
#image-da-container.da-container-split .dropzone { opacity: 0; } 

/* --- ÉTATS DES PREVIEWS --- */
#previews-group {
    width: 100%; display: flex; flex-direction: row; gap: 0px;
    transition: all 0.4s ease;
    position: relative; z-index: 1; /* Reste sous la zone de clic */
}
#previews-group.previews-hidden { opacity: 0; visibility: hidden; height: 0; }
#previews-group.previews-visible { opacity: 1; visibility: visible; height: auto; }

.da-preview-box {
    flex: 1; padding: 1.5rem; border-right: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column; align-items: center;
}
.da-preview-box:last-child { border-right: none; }

.da-preview-label {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px;
    color: var(--color-accent); margin-bottom: 1rem; font-weight: bold; text-align: center;
}

#da-bloc-wrapper, #da-cadrage-wrapper {
    position: relative; width: 100%; overflow: hidden; background: #050505;
    border-radius: 4px; border: 1px solid rgba(255,255,255,0.05);
}

#image-preview-bloc, #image-preview-cadrage {
    position: absolute; top: 0; left: 0;
    width: 100% !important; height: 100% !important;
    object-fit: cover !important; transition: object-position 0.4s ease;
}

/* =========================================
   RESTAURATION & SÉCURITÉ DES BOÎTES DE D.A.
   ========================================= */

/* 1. La boîte du Bloc Bento (Gauche) */
#da-bloc-wrapper { 
    max-width: 300px; 
    aspect-ratio: 1 / 1; 
    margin: 0 auto; 
    transition: all 0.4s ease; 
    display: block;
}
#da-bloc-wrapper.bento-big { aspect-ratio: 1 / 1; max-width: 100%; }
#da-bloc-wrapper.bento-tall { aspect-ratio: 1 / 2; max-width: 200px; }
#da-bloc-wrapper.bento-wide { aspect-ratio: 2 / 1; max-width: 100%; }

/* 2. La boîte du Cadrage En-tête (Celle qui était cassée - Droite) */
#da-cadrage-wrapper { 
    width: 100%; 
    max-width: 100%; 
    aspect-ratio: 21 / 9; /* Le format panoramique de ton en-tête public */
    margin: auto 0;
    display: block;
    min-height: 150px; /* Sécurité absolue pour empêcher l'écrasement */
    border-radius: 4px;
}

/* =========================================================
   CORRECTION DÉBORDEMENT MOBILE (ADMIN)
   ========================================================= */
@media (max-width: 768px) {
    /* 1. On réduit les marges du panneau pour récupérer de l'espace */
    .admin-content {
        padding: 1rem !important;
    }
    .panel {
        padding: 1.5rem 1rem !important;
    }

    /* 2. On empile les boîtes de prévisualisation à la verticale */
    #previews-group {
        flex-direction: column !important;
    }
    .da-preview-box {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding: 1rem 0 !important;
    }
    .da-preview-box:last-child {
        border-bottom: none !important;
    }

    /* 3. On réduit la taille de la boîte de cadrage pour qu'elle rentre parfaitement */
    #da-cadrage-wrapper {
        min-height: 100px !important;
    }

    /* 4. On autorise les boutons "Annuler" et "Enregistrer" à s'empiler */
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    .form-actions button {
        width: 100%;
    }

    /* 5. Sécurité absolue contre le débordement des longues URLs (YouTube) */
    input, select, textarea {
        max-width: 100%;
    }
}

/* =========================================================
   SÉCURITÉ ANTI-DÉBORDEMENT MOBILE (LE BLINDAGE ABSOLU)
   ========================================================= */
@media (max-width: 768px) {
    /* 1. On interdit physiquement à la page de déborder à l'horizontal */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }

    /* 2. On contraint tous les conteneurs du formulaire à la taille de l'écran */
    .admin-layout, .admin-content, .dashboard-grid, .panel, #view-form {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin: 0 !important;
        overflow-x: hidden !important;
    }

    /* 3. LE CORRECTIF CLÉ : On casse les "min-width: 200px" des listes déroulantes */
    .form-group {
        display: flex !important;
        flex-direction: column !important; /* Force l'empilement vertical pur */
        gap: 15px !important;
        width: 100% !important;
    }
    .form-group > div {
        width: 100% !important;
        min-width: 100% !important; /* Annule les 200px du HTML */
        flex: none !important;
        margin: 0 !important;
    }

    /* 4. On force les champs de texte et sélecteurs à rester dans leurs boîtes */
    input, select, textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 5. On empile proprement les deux boîtes de Direction Artistique */
    #previews-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    .da-preview-box {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 1rem 0 !important;
        border-right: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    .da-preview-box:last-child {
        border-bottom: none !important;
    }

    /* 6. On s'assure que l'image Bento rétrécit pour rentrer sur l'écran */
    #da-bloc-wrapper {
        max-width: 200px !important; 
    }
}

/* =========================================================
   STYLE DES SLIDERS DE DIRECTION ARTISTIQUE
   ========================================================= */
.da-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    margin: 10px 0;
}
.da-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent); /* La pastille Rouge */
    cursor: pointer;
    transition: transform 0.2s;
}
.da-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3); /* Effet d'agrandissement au survol */
}

/* =========================================================
   SCROLL INTERNE & RECHERCHE (LISTE PROJETS)
   ========================================================= */
.list-scroll-container {
    max-height: calc(100vh - 280px); /* Calcule la hauteur dispo sur PC */
    overflow-y: auto; /* Active le scroll uniquement si ça déborde */
    padding-right: 10px; /* Espace pour la barre de défilement */
}

/* Design de la Scrollbar (Style Premium / macOS) */
.list-scroll-container::-webkit-scrollbar {
    width: 6px;
}
.list-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}
.list-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}
.list-scroll-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent); /* Devient rouge au survol */
}

/* Ajustement intelligent pour les téléphones */
@media (max-width: 768px) {
    .list-scroll-container {
        /* Sur mobile, l'en-tête prend plus de place, on ajuste le calcul */
        max-height: calc(100vh - 350px) !important; 
    }
}

/* =========================================================
   STYLE AVATAR ÉQUIPE (ADMIN)
   ========================================================= */
#team-dropzone {
    cursor: pointer;
    transition: border-color 0.3s;
}
#team-dropzone:hover {
    border-color: var(--color-accent) !important;
}
#team-dropzone:hover .team-hover-text {
    opacity: 1 !important;
}

/* =========================================================
   BLINDAGE ANTI-STRETCH (ADMIN)
   ========================================================= */
.anti-stretch-img {
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.anti-stretch-img.loaded {
    opacity: 1;
}

/* Verrouillage strict des petites vignettes de liste */
.item-thumb.anti-stretch-img {
    width: 50px !important;
    height: 50px !important;
    object-fit: cover !important;
    display: block;
}

/* ========================================= */
/* COMPOSANT : SLIDER ON/OFF (TOGGLE SWITCH) */
/* ========================================= */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}

/* On cache la vraie case à cocher moche */
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Le fond du slider (Gris par défaut) */
.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #333; /* Couleur quand c'est OFF */
  transition: .3s;
  border-radius: 24px;
  border: 1px solid #444;
}

/* Le bouton rond à l'intérieur */
.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* L'état activé (ON) */
.toggle-switch input:checked + .slider {
  background-color: var(--color-accent, #4CAF50); /* Utilise ta couleur d'accentuation, ou du vert */
  border-color: var(--color-accent, #4CAF50);
}

/* Le déplacement du bouton rond quand activé */
.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}
