/**
 * @file carousel.css
 * @description Styles du slider MonAppli Netflix-like :
 * - Bloc Bienvenue + CTA toujours visible
 * - Slides avec texte dynamique (coin différent à chaque slide)
 * - Responsive, fluide, border-radius, ombres, accessibilité
 */

/* =============== SLIDER CONTAINER =============== */
.slider {
    position: relative;
    width: 100%;
    height: 70vh;
    min-height: 320px;
    max-width: 1600px;
    margin: 0 auto 48px auto;
    background: #000;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
    overflow: hidden;
    color: #fff;
}

/* =============== ZONE DE SLIDES =============== */
.slider .list {
    position: relative;
    height: 100%;
}
.slider .list .item {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1s;
    z-index: 1;
}
.slider .list .item.active {
    opacity: 1;
    z-index: 2;
}
.slider .list .item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

/* =============== TEXTE DYNAMIQUE DE SLIDE =============== */
.dynamic-content {
    position: absolute;
    background: rgba(0,0,0,0.60);
    color: #fff;
    padding: 24px 28px;
    border-radius: 10px;
    max-width: 450px;
    min-width: 220px;
    font-size: 1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.28);
    text-align: left;
    z-index: 4;
    transition: all 0.5s;
}
.dynamic-content h3 {
    font-size: 1.4em;
    font-weight: 700;
    margin-bottom: 10px;
    color: #f27c06;
    text-shadow: 2px 2px 5px #111;
}
.dynamic-content p {
    margin-bottom: 0;
    font-size: 1em;
    line-height: 1.5;
}
/* Variantes de position dynamiques */
.dynamic-content.top-left {
    top: 8%;
    left: 5%;
    margin-top: 100px;
}
.dynamic-content.top-right {
    top: 8%;
    right: 5%;
    text-align: left;
    margin-top: 100px;
}
.dynamic-content.bottom-right {
    bottom: 8%;
    right: 5%;
    text-align: left;
}
.dynamic-content.bottom-left {
    bottom: 8%;
    left: 5%;
}

/* =============== OVERLAY HEADER DESKTOP =============== */
.global-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 30;
    text-align: center;
    background: rgba(0,0,0,0.24);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
    padding: 11px 4px 4px 4px;
    /*pointer-events: none;*/
    display: block;
    transition: background 0.3s ease-in-out;
}

.global-overlay:hover {
    background: rgba(0, 0, 0, 0.75); /* Fond plus sombre au survol */
}

.global-overlay .overlay-inner {
    max-width: 630px;
    margin: 0 auto;
    pointer-events: auto;
}
.global-overlay h1 {
    font-size: clamp(1.18rem, 4vw, 1.47rem);
    margin: 0 0 2px 0;
    color: #f27c06;
    font-weight: 700;
    line-height: 1.13;
    text-shadow: 1px 1px 5px #222;
}
.global-overlay p {
    font-size: .98rem;
    margin-bottom: 7px;
    color: #fff;
    text-shadow: 1px 1px 4px #222;
}
.cta-buttons {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-bottom: 0;
}
.btn-slider {
    background: #f27c06;
    color: #222;
    font-weight: 700;
    font-size: .95rem;
    border-radius: 6px;
    padding: 7px 12px;
    text-decoration: none;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    transition: background 0.25s, color 0.25s;
    min-width: 130px;
    max-width: 200px;
}
.btn-slider:hover {
    background: #ffc107;
    color: #111;
    transform: translateY(-1px);
}

/* =============== OVERLAY MOBILE (au-dessus du slider, hors .slider) =============== */
.global-overlay-mobile { 
    display: none; 
}

/* ----------- OVERLAY MOBILE (blanc, texte noir, hors slider) ----------- */
@media screen and (max-width: 700px) {
  .global-overlay { display: none !important; }
  
  .global-overlay-mobile {
    display: block;
    position: sticky;
    top: 0;
    left: 0;
    width: 100%; /* On remplace 100vw par 100% pour plus de sûreté */
    box-sizing: border-box; /* <<< LA CORRECTION CLÉ : inclut le padding dans la largeur totale */
    z-index: 9999;
    background: #fff;
    color: #222;
    box-shadow: 0 4px 12px rgba(0,0,0,0.09);
    border-radius: 14px;
    padding: 16px; /* Un padding uniforme et un peu plus aéré */
    margin-bottom: 16px;
    text-align: center;
  }
  
  .global-overlay-mobile .overlay-inner {
    max-width: 100%; /* Le conteneur interne peut prendre toute la place */
    margin: 0 auto;
    pointer-events: auto;
  }
  
  .global-overlay-mobile h1 {
    font-size: 1.15rem; /* Légèrement plus grand pour la lisibilité */
    color: #f27c06; 
    font-weight: 700; 
    margin: 0 0 8px 0; /* Un peu plus d'espace en dessous */
    line-height: 1.2; 
    text-shadow: none;
  }
  
  .global-overlay-mobile p {
    font-size: 0.95rem; 
    color: #333; /* Un peu moins dur que le noir pur */
    margin: 0 0 16px 0; /* Plus d'espace avant les boutons */
    line-height: 1.5; /* Meilleur interlignage */
    text-shadow: none;
  }
  
  .cta-buttons {
    flex-direction: column; 
    gap: 9px;
  }
  
  .btn-slider {
    width: 100%; /* Le bouton prend toute la largeur disponible */
    max-width: 320px;
    font-size: 1rem;
    margin: 0 auto;
    padding-top: 10px;    
    padding-bottom: 10px; 
    background: #ffa726;
    color: #222;
  }
}

/* ----------- TEXTE DYNAMIQUE EN BAS DU SLIDER SUR MOBILE ----------- */
@media screen and (max-width: 700px) {
  .dynamic-content,
  .dynamic-content.top-left,
  .dynamic-content.top-right,
  .dynamic-content.bottom-left,
  .dynamic-content.bottom-right {
    position: static !important;
    max-width: 97vw !important;
    margin: 0 auto 0 auto !important;
    padding: 13px 9px 17px 9px !important;
    border-radius: 10px;
    background: rgba(0,0,0,0.72);
    color: #fff;
    text-align: center !important;
    box-shadow: 0 4px 11px rgba(0,0,0,0.10);
    font-size: 0.97em;
  }
  .slider .list .item {
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
  }
}

/* ----------- TEXTE DYNAMIQUE EN BAS SUR MOBILE ----------- */
@media (max-width: 700px) {

    /**
     * 1. Le conteneur principal du slider a une hauteur automatique.
     * Ceci ne change pas, c'est la base de la solution.
     */
    .slider {
        height: auto !important;
        background: #000;
    }

    /* On cache les contrôles qui ne sont plus pertinents */
    .slider #prev, .slider #next, .slider .thumbnail, .slider .time {
        display: none !important;
    }

    /**
     * 2. Voici la correction clé :
     * - Chaque 'item' est dans le flux normal (position relative).
     * - On les cache non pas avec 'display: none' mais en les faisant s'effondrer :
     * 'max-height: 0' et 'overflow: hidden'.
     */
    .slider .item {
        position: relative !important; /* Dans le flux, mais peut contenir des éléments absolus si besoin */
        display: flex !important; /* On garde flex pour la structure interne */
        flex-direction: column !important;
        
        /* On effondre les slides inactifs */
        max-height: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        
        /* On ajoute une transition pour un effet fluide */
        transition: opacity 0.4s ease-out, max-height 0.6s ease-out;
    }

    /**
     * 3. Seul l'item ACTIF retrouve sa hauteur et devient visible.
     * On lui donne une 'max-height' très grande pour qu'il puisse s'étendre.
     */
    .slider .item.active {
        max-height: 150vh !important; /* Assez grand pour n'importe quel contenu */
        opacity: 1 !important;
    }
    
    /**
     * 4. Le style de l'image et du texte reste le même.
     */
    .slider .item img {
        height: 45vh;
        min-height: 280px;
        width: 100%;
        object-fit: cover;
        border-radius: 12px 12px 0 0 !important;
    }

    .dynamic-content,
    .dynamic-content.top-left,
    .dynamic-content.top-right,
    .dynamic-content.bottom-left,
    .dynamic-content.bottom-right {
        position: static !important;
        transform: none !important;
        top: auto !important; left: auto !important; right: auto !important; bottom: auto !important;
        width: 100%;
        max-width: 100% !important;
        margin: 0 !important;
        background: #1e1e1e;
        padding: 20px 15px !important;
        text-align: left !important;
        border-radius: 0 0 12px 12px !important;
        box-sizing: border-box;
    }
}

/* =============== FLECHES NAVIGATION =============== */
.slider #prev, .slider #next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 30px;
    background: rgba(0,0,0,0.50);
    color: #fff;
    border: none;
    width: 46px;
    height: 46px;
    cursor: pointer;
    z-index: 15;
    border-radius: 50%;
    transition: background 0.3s;
}
.slider #prev { left: 18px; }
.slider #next { right: 18px; }
.slider #prev:hover, .slider #next:hover {
    background: rgba(255,255,255,0.16);
}

/* =============== DOTS (POINTS) =============== */
.slider .thumbnail {
    position: absolute;
    bottom: 18px;
    width: 100%;
    text-align: center;
    z-index: 10;
}
.slider .thumbnail .item {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin: 0 4px;
    background: #aaa;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}
.slider .thumbnail .item.active {
    background: #fff;
}

/* =============== BARRE DE PROGRESSION =============== */
.slider .time {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: #ffcc00;
    width: 0%;
    z-index: 12;
    transition: width 0.2s;
}

/* =============== RESPONSIVE =============== */
@media (max-width: 1024px) {
    .slider { height: 44vh; }
    .dynamic-content { max-width: 70vw; }
    .global-overlay { padding: 24px 8px; }
}
@media (max-width: 600px) {
    .slider { height: 36vh; }
    .dynamic-content,
    .global-overlay { 
        max-width: 96vw;
        min-width: unset;
        padding: 14px 8px; 
        font-size: .97em;
        left: 50%!important;
        right: unset!important;
        top: unset!important;
        bottom: 8%!important;
        transform: translateX(-50%);
        text-align: center;
    }
    .global-overlay h1 { font-size: 1.35rem; }
    .cta-buttons { flex-direction: column; gap: 11px;}
    .btn-slider { width: 90%; max-width: 290px; font-size: 0.95em;}
    .slider #prev, .slider #next { width: 35px; height: 35px; font-size: 19px; }
    .slider .thumbnail .item { width: 10px; height: 10px; }
}
