/* ==========================================
   1. STRUCTURE GÉNÉRALE ET BODY
   ========================================== */
html, body { height: 100%; margin: 0; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Georgia', serif;
    background-color: #000;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url("../images/arrière plan.png") center/cover no-repeat;
    opacity: 0.6;
    z-index: -1;
}

main { flex: 1; position: relative; z-index: 1; }

header, footer { background-color: #66051d; color: #ffffff; padding: 20px 0; text-align: center; }

hr { width: 50%; border: 1px solid #ffffff; margin: 20px 0; }


/* ==========================================
   2. NAVIGATION ET PIED DE PAGE
   ========================================== */
nav ul { list-style: none; padding: 0; display: flex; justify-content: center; gap: 30px; }
nav a { color: #ffffff; text-decoration: none; font-weight: bold; }
nav a:hover { text-decoration: underline; }


/* ==========================================
   3. SECTIONS DE TEXTE (HERO / INTRO)
   ========================================== */
.hero, .intro-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px;
}

.hero h1, .hero h2, .intro-text h1, .intro-text h2,
.hero p, .intro-text p {
    text-align: center;
    color: #ffffff;
    max-width: 800px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

/* Force la lisibilité sur fond sombre */
section.intro-text, section.hero {
    background-color: rgba(0, 0, 0, 0.7) !important;
    padding: 40px !important;
    border-radius: 15px !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    margin: 20px auto !important;
    max-width: 900px !important;
}

section.intro-text *, section.hero *, .intro-text h2, .intro-text p, .intro-text label, .intro-text span {
    color: #ffffff !important;
}

.intro-text a:not(.btn) {
    color: #ffc107 !important;
    text-decoration: underline;
}


/* ==========================================
   4. HARMONISATION DES BOUTONS (ROUGE)
   ========================================== */
.btn, input[type="submit"], .btn-group a, .container-bouton-ligne a {
    background-color: #66051d !important;
    color: #ffffff !important;
    border: 2px solid #66051d !important;
    padding: 10px 20px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
    text-align: center;
    transition: all 0.3s ease !important;
    border-radius: 5px;
    font-weight: bold;
    text-decoration: none;
}

.btn:hover, input[type="submit"]:hover, .btn-group a:hover, .container-bouton-ligne a:hover {
    background-color: transparent !important;
    color: #66051d !important;
    border: 2px solid #66051d !important;
}

.btn-group {
    display: flex;
    flex-direction: column; 
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.container-bouton-ligne {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 20px;
}

/* Cas particulier : Boutons Accueil */
.container-bouton-ligne a[href="index.php"], .container-bouton-ligne a[href="../index.php"],
.btn-group a[href="index.php"], .btn-group a[href="../index.php"] {
    background-color: transparent !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}


/* ==========================================
   5. CATALOGUE ET RECHERCHE
   ========================================== */
.liste-vins {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    padding: 20px;
}

.carte {
    background-color: rgba(255, 255, 255, 0.95) !important;
    border-radius: 15px;
    width: 300px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid #66051d;
    color: #333 !important;
}

.carte img { width: 100%; height: 200px; object-fit: cover; }
.carte-content { padding: 15px; }
.carte-content h3 { color: #66051d !important; margin-top: 0; }
.carte-content .description { color: #444444 !important; }

/* Formulaire de recherche */
.form-recherche { display: flex; flex-direction: column; align-items: center; width: 100%; }
.form-recherche input[type="text"], .form-recherche input[type="number"] {
    padding: 10px;
    width: 300px;
    margin-bottom: 15px;
    border-radius: 5px;
    border: 1px solid #ccc;
    color: #000 !important;
    background-color: #fff !important;
}


/* ==========================================
   6. ADMINISTRATION ET GESTION (TABLEAUX / FORM)
   ========================================== */
.tableau-admin {
    width: 90%;
    margin: 30px auto;
    border-collapse: collapse;
    background-color: rgba(255, 255, 255, 0.9);
    color: #000 !important;
}
.tableau-admin th, .tableau-admin td { border: 1px solid #66051d; padding: 12px; text-align: center; vertical-align: middle; }
.tableau-admin th { background-color: #66051d; color: #fff; }

.img-tableau {
    width: 60px; height: auto; max-height: 80px; display: block; margin: 0 auto; border-radius: 4px; object-fit: contain;
}
.img-tableau:hover {
    transform: scale(2.5); transition: transform 0.2s; position: relative; z-index: 99; box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Formulaire de Gestion Admin */
.form-gestion {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 500px !important;
    background-color: rgba(102, 5, 29, 0.8) !important;
    padding: 30px !important;
    border-radius: 10px !important;
}

.form-gestion input, .form-gestion select, .form-gestion textarea {
    width: 100% !important; max-width: 100% !important; margin-bottom: 15px !important; box-sizing: border-box !important;
    color: #000 !important; background-color: #fff !important; padding: 8px; border-radius: 4px; border: 1px solid #ccc;
}

.form-gestion input[type="submit"] { border: 3px solid #ffffff !important; }

.image-accueil {
    width: 250px; height: 150px; object-fit: cover; border-radius: 10px; border: 2px solid #66051d;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); margin-bottom: 10px;
}
.image-accueil:hover { transform: scale(1.05); transition: transform 0.3s ease; border-color: #ffffff; }

.conteneur-photo-edit {
    display: flex; align-items: center; gap: 20px; padding: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.05);
}

/* --- 7. RÉGLAGES DE CONTRASTE (DÉPLACÉS À LA FIN POUR QUE ÇA MARCHE) --- */

/* Fond sombre -> Écriture blanche */
section.intro-text, section.hero, .form-recherche label {
    color: #ffffff !important;
}
section.intro-text *, section.hero * {
    color: #ffffff;
}

/* Fond blanc (Cartes et Tableaux) -> ÉCRITURE NOIRE FORCÉE */
.carte, 
.carte *, 
.carte-content p, 
.carte-content strong, 
.carte-content span,
.tableau-admin, 
.tableau-admin td {
    color: #000000 !important; /* Ici on force le noir sur le blanc */
}

/* Exception pour le titre de la carte qui reste bordeaux */
.carte-content h3 {
    color: #66051d !important;
}

/* Inputs (Écriture noire dans cases blanches) */
input, select, textarea {
    color: #000000 !important;
    background-color: #ffffff !important;
}
/* FORCE L'ÉCRITURE NOIRE DANS LES CARTES (À mettre tout en bas du fichier) */
.carte, 
.carte-content, 
.carte-content * {
    color: #000000 !important;
}

/* Préserve le titre en bordeaux */
.carte-content h3 {
    color: #66051d !important;
}

/* Préserve la description en gris foncé */
.carte-content .description, 
.carte-content .description i {
    color: #444444 !important;
}

/* --- CENTRAGE DES RÉSULTATS DE RECHERCHE --- */

/* 1. Centre le texte qui annonce le nombre de résultats */
.liste-vins p {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
}

/* 2. Centre la grille de cartes elle-même */
.liste-vins {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Aligne les cartes au milieu horizontalement */
    gap: 30px;
    padding: 20px;
    width: 100%;
}

/* 3. Assure que la section parente laisse de la place au centrage */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centre tout le bloc hero */
    width: 100%;
}

/* --- STYLE DE LA DESCRIPTION DU HAUT UNIQUEMENT --- */

/* Le ">" dit : seulement le paragraphe directement sous .hero ou .intro-text */
.hero > p, 
.intro-text > p {
    font-size: 1.1rem;
    line-height: 1.8;
    letter-spacing: 0.5px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9) !important;
    max-width: 700px;
    margin: 20px auto;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* La lettrine (première lettre dorée) uniquement pour la description du haut */
.hero > p::first-letter, 
.intro-text > p::first-letter {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffc107;
}

/* --- PROTECTION DES CARTES --- */
/* On s'assure que les paragraphes dans les cartes restent normaux */
.carte-content p {
    font-style: normal !important;
    font-size: 1rem !important;
    line-height: normal !important;
    text-shadow: none !important;
    margin: 5px 0 !important;
}

/* --- SECTION IMAGES ACCUEIL --- */

.image-index {
    display: flex;
    justify-content: center; /* Centre les 3 cartes */
    gap: 20px;               /* Espace entre les cartes */
    margin-top: 40px;
    flex-wrap: wrap;         /* Pour le mobile */
}

.vin-card {
    background-color: rgba(255, 255, 255, 0.95); /* Fond blanc cassé */
    padding: 10px;
    border-radius: 12px;
    width: 200px;            /* Largeur des mini-cartes */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    border: 1px solid #66051d;
}

.vin-card:hover {
    transform: translateY(-5px); /* Petit effet de survol */
}

.vin-card img {
    width: 100%;             /* L'image prend toute la largeur du bloc */
    height: 150px;           /* Hauteur fixe pour l'harmonie */
    object-fit: cover;       /* Recadre proprement */
    border-radius: 8px;      /* Arrondi de l'image */
}

/* ÉCRITURE NOIRE SUR BLANC (Ta règle) */
.vin-card p {
    color: #000000 !important; 
    font-size: 0.9rem;
    margin-top: 10px;
    text-align: center;
    line-height: 1.4;
    font-style: normal !important; /* On enlève l'italique ici */
    text-shadow: none !important;  /* On enlève l'ombre portée pour la clarté */
}

.vin-card strong {
    color: #66051d; /* Titre du vin en bordeaux */
    font-size: 1rem;
    display: block;
    margin-bottom: 5px;
}

/* --- FORCE LE NOIR SUR LES CARTES DE L'INDEX --- */

.vin-card, 
.vin-card p, 
.vin-card strong {
    color: #000000 !important; /* Force le noir */
    text-shadow: none !important; /* Enlève l'ombre portée blanche */
    font-style: normal !important; /* Enlève l'italique si hérité */
}

.vin-card strong {
    color: #ffffff !important; /* On garde le titre en bordeaux pour le style */
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
}

/* On s'assure que le fond de la carte est bien opaque pour la lisibilité */
.vin-card {
    background-color: rgba(255, 255, 255, 0.95) !important;
}

/* --- 1. CONTENEUR PRINCIPAL (FENÊTRE) --- */
.image-index {
    width: 100%;
    overflow: hidden; /* Cache les images qui sortent de l'écran */
    margin: 50px auto;
    padding: 20px 0;
    position: relative;
    /* Optionnel : un léger dégradé pour adoucir les bords du carrousel */
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

/* --- 2. LE RAIL (L'ÉLÉMENT QUI BOUGE) --- */
.image-index-inner {
    display: flex;
    gap: 30px; /* Espace entre les blocs noirs */
    width: max-content; /* Permet au rail d'être aussi large que nécessaire */
    animation: defilement-infini 25s linear infinite;
}

/* --- 3. LES BLOCS DE VINS (STYLE NOIR & ROUGE) --- */
.vin-card {
    flex: 0 0 280px; /* Largeur fixe de chaque bloc */
    background-color: #000000 !important; /* Bloc noir */
    border: 2px solid #66051d; /* Bordure rouge bordeaux */
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

/* Effet au survol : la bordure s'illumine un peu */
.vin-card:hover { 
    transform: scale(1.02);
}

/* --- 4. IMAGES ET TEXTES --- */
.vin-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 10px;
    border-bottom: 1px solid #66051d; /* Petite séparation sous l'image */
}

.vin-card p {
    color: #ffffff !important; /* Texte blanc pour ressortir sur le noir */
    text-align: center;
    margin-top: 15px;
    font-style: normal !important;
    text-shadow: none !important;
}

.vin-card strong {

    font-size: 1.1rem;
    display: block;
    margin-bottom: 5px;
}

/* --- 5. L'ANIMATION MAGIQUE --- */
@keyframes defilement-infini {
    0% {
        transform: translateX(0);
    }
    100% {
        /* On décale de -50% car on a doublé les éléments en PHP */
        transform: translateX(-50%);
    }
}

/* Pause l'animation quand on passe la souris pour pouvoir lire */
.image-index:hover .image-index-inner {
    animation-play-state: paused;
}


/* ==========================================================
   CSS RÉPONSIVE GLOBAL (POUR TOUTES LES PAGES)
   ========================================================== */

@media screen and (max-width: 768px) {
    
    /* 1. VERROUILLAGE DE LA LARGEUR (ANTI-DÉBORDEMENT) */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        position: relative;
        margin: 0;
        padding: 0;
    }

    /* 2. HEADER & NAVIGATION (S'empile sur toutes les pages) */
    header, nav, nav ul {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        text-align: center;
        padding: 10px 0 !important;
        gap: 10px !important;
    }

    /* 3. CONTENEURS DE PAGES (Listing, Admin, Index) */
    /* On cible ici tous tes conteneurs principaux */
    section, .container, .admin-section, .hero, .vin-list {
        width: 100% !important;
        max-width: 100% !important;
        padding: 15px !important;
        box-sizing: border-box !important; /* Force le calcul interne */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    /* 4. LE CARROUSEL (Redevient statique en colonne) */
    .image-index {
        width: 100% !important;
        overflow: hidden !important;
    }

    .image-index-inner {
        flex-direction: column !important;
        animation: none !important; /* Stop le mouvement qui fait sortir du cadre */
        transform: none !important;
        width: 100% !important;
        gap: 20px !important;
    }

    /* 5. LES CARTES ET ÉLÉMENTS INDIVIDUELS */
    /* Que ce soit sur l'index ou le listing */
    .vin-card, .vin-item, .btn-group {
        width: 95% !important; /* Prend la largeur dispo sans toucher les bords */
        max-width: 350px !important;
        flex-direction: column !important; /* Aligne l'image et le texte verticalement */
        margin: 10px auto !important;
        box-sizing: border-box;
    }

    /* 6. IMAGES (Ajustement automatique) */
    img {
        max-width: 100% !important;
        height: auto !important; /* Garde les proportions sans déformer */
    }

    /* 7. TABLEAUX & FORMULAIRES */
    /* Si tu as des tableaux, ils doivent pouvoir scroller ou se transformer */
    table {
        display: block !important;
        overflow-x: auto !important;
        width: 100% !important;
    }

    /* 8. TYPOGRAPHIE (On réduit pour que ça rentre) */
    h1, h2 {
        font-size: 1.4rem !important;
        word-wrap: break-word;
    }

    p {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
    }
}