/* --- RESET & BASE --- */
* { box-sizing: border-box; }
:root {
    --primary-color: #000;
    --accent-beige: #B49282;
    --light-beige: #F5DBC4;
    --bg-gray: #f8f9fa;
    --text-color: #333;
    --text-muted: #777;
    --border-color: #e0e0e0;
    --sale-pink: black;
}

a, button, input, select, textarea,
.carousel-btn, 
.thumbnail-img, 
.btn-fav-detail, 
.btn-toggle-desc, 
.stylish-select, 
.close-zoom-btn,
.btn-add-cart {
    touch-action: manipulation;
}

body { font-family: 'Segoe UI', sans-serif; color: var(--text-color); background-color: var(--bg-gray); margin: 0; padding: 0; overflow-x: hidden; }

/* --- LAYOUT PRINCIPAL --- */
.product-page { max-width: 1200px; margin: 40px auto; padding: 0 20px; }

.product-main-wrapper {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 50px;
    margin-bottom: 80px;
    width: 100%;
}

.product-gallery-column, .product-info-column { padding-top: 10px; }

/* --- TITRE MOBILE (Caché par défaut sur Desktop) --- */
.mobile-product-header {
    display: none; /* Desktop */
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* --- GALERIE --- */
.product-gallery-column { position: relative; }
.carousel-main-view {
    position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 500px;
    background: #fff; border-radius: 8px; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color);
}
.carousel-container { display: flex; width: 100%; height: 100%; transition: transform 0.5s ease; }
.carousel-slide { min-width: 100%; display: flex; align-items: center; justify-content: center; height: 100%; }
.carousel-slide img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }

.carousel-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.9); border: none; width: 40px; height: 40px;
    border-radius: 50%; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10; font-size: 18px; display: flex; align-items: center; justify-content: center;
    color: var(--primary-color); transition: background 0.3s;
}
.carousel-btn:hover { background: #fff; color: var(--accent-beige); }
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-btn.hidden { display: none; }

.carousel-thumbnails {
    display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; 
    overflow-x: visible; padding-bottom: 10px; justify-content: center; 
}
.thumbnail-img {
    width: 70px; height: 70px; object-fit: cover; border: 2px solid transparent;
    cursor: pointer; border-radius: 4px; opacity: 0.6; transition: 0.3s;
    flex-shrink: 0; background: #fff;
}
.thumbnail-img.active, .thumbnail-img:hover { border-color: var(--accent-beige); opacity: 1; }

/* --- INFOS --- */
.title-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.product-title {
    font-size: 2rem; margin: 0; font-weight: 700; line-height: 1.2;
    word-wrap: break-word; flex: 1; margin-right: 15px; color: var(--primary-color);
}

.btn-fav-detail {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border-color);
    background-color: #fff; display: flex; align-items: center; justify-content: center;
    color: #aaa; transition: all 0.3s ease; text-decoration: none; font-size: 1.2rem; flex-shrink: 0; 
}
.btn-fav-detail:hover { border-color: var(--accent-beige); color: var(--accent-beige); transform: scale(1.05); }
.btn-fav-detail.active { color: #d9534f; border-color: #d9534f; background-color: #fff5f5; }

.product-cat-label { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; text-transform: uppercase; letter-spacing: 1px; }

/* PRIX */
.price-rating-row { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 20px; gap: 5px; }
.product-price-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#prix-affiche { font-size: 1.8rem; font-weight: 700; color: var(--primary-color); }
.promo-price { color: var(--sale-pink) !important; }
.old-price { font-size: 1.2rem; text-decoration: line-through; color: var(--text-muted); }
.sale-badge, .badge-black {
    background-color: #000; color: #fff; font-size: 0.75rem; font-weight: bold;
    padding: 4px 8px; border-radius: 2px; text-transform: uppercase; display: inline-block;
}
.product-rating { font-size: 0.9rem; margin-top: 5px; }
.stars { color: #ffc107; }
.review-link { color: var(--text-muted); text-decoration: none; margin-left: 5px; }

.separator { border: none; border-top: 1px solid var(--border-color); margin: 20px 0; }

/* DESCRIPTION */
.btn-toggle-desc {
    width: 100%; background: none; border: none; border-bottom: 1px solid var(--border-color);
    padding: 15px 0; text-align: left; font-size: 1rem; font-weight: 600;
    color: var(--primary-color); cursor: pointer; display: flex; justify-content: space-between;
    align-items: center; transition: color 0.3s;
}
.btn-toggle-desc:hover { color: var(--primary-color); }
.description-content { max-height: 0; overflow: hidden; transition: max-height 0.4s ease-out; color: #555; line-height: 1.6; }
.description-content.open { max-height: 500px; padding: 15px 0; }

/* FORMULAIRE (Options) */
.add-to-cart-form { margin-top: 30px; }
.option-group { margin-bottom: 20px; }
.option-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; color: var(--primary-color); }
.stylish-select {
    width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px;
    font-size: 1rem; background-color: #fff; cursor: pointer; color: var(--text-color);
}
.stylish-select:focus { border-color: var(--accent-beige); outline: none; }

/* Champ de personnalisation (gravure collier) */
.personnalisation-group {
    background: linear-gradient(135deg, #fdf8f5 0%, #fff 100%);
    border: 2px dashed var(--accent-beige);
    padding: 20px;
    border-radius: 12px;
    margin-top: 25px;
    margin-bottom: 25px;
}
.personnalisation-group label {
    color: var(--accent-beige);
    font-size: 1rem;
}
.personnalisation-group label i {
    margin-right: 8px;
}
.input-personnalise {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--accent-beige);
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: 'Georgia', serif;
    letter-spacing: 1px;
    text-align: center;
    background-color: #fff;
    transition: all 0.3s ease;
}
.input-personnalise:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(180, 146, 130, 0.2);
}
.input-personnalise::placeholder {
    color: #bbb;
    font-style: italic;
}
.hint-text {
    display: block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.actions-row { display: flex; gap: 15px; margin-top: 30px; align-items: flex-end; }
.qty-selector { width: 80px; }
.btn-add-cart {
    width: auto; min-width: 180px; padding: 10px 30px; background-color: var(--primary-color);
    color: white; border: none; font-size: 1rem; font-weight: 600; border-radius: 50px;
    cursor: pointer; transition: all 0.3s; display: flex; align-items: center; justify-content: center; height: 45px; 
}
.btn-add-cart:hover:not(:disabled) { background-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.btn-add-cart:disabled { background-color: #ccc; cursor: not-allowed; }

.trust-badges {
    display: flex; justify-content: space-around; margin-top: 30px; background: #fff;
    padding: 15px; border-radius: 8px; font-size: 0.85rem; color: var(--text-muted);
    border: 1px solid var(--border-color);
}
.trust-badges i { color: var(--accent-beige); margin-right: 5px; font-size: 1.1rem; }

/* AVIS */
.reviews-wrapper { border-top: 1px solid var(--border-color); padding-top: 40px; margin-top: 40px; }
.section-title { font-size: 1.5rem; margin-bottom: 30px; color: var(--primary-color); }
.review-card { background: #fff; border: 1px solid var(--border-color); padding: 20px; border-radius: 8px; margin-bottom: 20px; }
.review-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.add-review-box { background: #fff; padding: 30px; border-radius: 8px; margin-top: 40px; border: 1px solid var(--border-color); }
.add-review-box textarea { width: 100%; border: 1px solid var(--border-color); border-radius: 6px; padding: 10px; }
.btn-submit-review { background-color: var(--primary-color); color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; margin-top: 10px; }

/* ZOOM MODAL */
.image-zoom-modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.95); justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease; }
.image-zoom-modal.show { opacity: 1; }
.zoom-content-container { position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
.modal-content-zoom { max-width: 90vw; max-height: 90vh; width: auto; height: auto; object-fit: contain; }
.close-zoom-btn { position: absolute; top: 20px; right: 30px; color: #fff; font-size: 40px; cursor: pointer; z-index: 2001; }


/* ================================================== */
/* ---------------- RESPONSIVE MOBILE --------------- */
/* ================================================== */

@media (max-width: 992px) {
    .product-main-wrapper { grid-template-columns: 1fr; gap: 30px; }
    .product-gallery-column { width: 100%; margin: 0 auto; }
}

@media (max-width: 768px) {
    .product-page { width: 100%; padding: 0 15px; margin-top: 15px; }
    
    .product-main-wrapper { 
        display: flex; /* Flexbox pour gérer l'ordre global */
        flex-direction: column;
        margin-bottom: 10px !important; 
    }

    /* ASTUCE : display: contents permet de "supprimer" les conteneurs colonnes
       pour que leurs enfants deviennent des items directs du wrapper flex */
    .product-gallery-column, 
    .product-info-column {
        display: contents;
    }

    /* --- ORDRE D'AFFICHAGE --- */

    /* 1. Titre */
    .mobile-product-header {
        display: flex; /* On l'affiche */
        order: 1;
        margin-bottom: 10px;
    }
    .mobile-product-header .product-title { font-size: 1.6rem; margin: 0; }

    /* 2. Prix & Avis */
    .price-rating-row {
        order: 2;
        margin-bottom: 15px;
        padding-top: 0;
        border-top: none;
        width: 100%;
    }

    /* 3. Galerie Images (MODIFIÉ POUR S'ADAPTER À L'IMAGE) */
    .produit-image-carousel { 
        order: 3;
        width: 100%;
        margin-bottom: 20px;
    }

    /* --- MODIFICATION CLÉ : Hauteur automatique sur Mobile --- */
    .carousel-main-view {
        width: 100%;
        height: auto;        /* Hauteur automatique (plus de hauteur fixe) */
        max-height: none;    /* Suppression de la limite */
        aspect-ratio: auto;  /* Suppression du format carré forcé */
        border: none;        /* Moins de bordures sur mobile pour le look "app" */
        background: transparent;
    }

    .carousel-container {
        height: auto;        /* Le conteneur s'adapte à la hauteur du contenu */
        align-items: flex-start; /* Aligne les images en haut */
    }

    .carousel-slide {
        height: auto;        /* La slide s'adapte aussi */
        display: block;      /* Utilisation du block standard */
    }

    .carousel-slide img {
        width: 100%;         /* L'image prend toute la largeur */
        height: auto;        /* L'image garde son ratio naturel */
        max-height: 85vh;    /* Sécurité : évite que l'image ne dépasse trop l'écran */
        object-fit: contain;
        display: block;      /* Supprime l'espace vide sous l'image */
    }
    /* --------------------------------------------------------- */

    /* 4. Options (Formulaire) */
    .add-to-cart-form {
        order: 4;
        margin-top: 0;
        margin-bottom: 20px;
        width: 100%;
    }

    /* 5. Description */
    .description-toggle-container {
        order: 5;
        width: 100%;
    }

    /* Elements à masquer */
    .desktop-product-header { display: none; }
    .product-cat-label { display: none; } 
    .desktop-separator { display: none; }

    /* Ajustements formulaires */
    .actions-row { flex-direction: column; align-items: stretch; gap: 15px; }
    .qty-selector { width: 100%; }
    .btn-add-cart { width: 100%; padding: 15px; font-size: 1.1rem; }

    /* Badges horizontaux */
    .trust-badges { 
        flex-direction: row; 
        flex-wrap: wrap; 
        justify-content: center;
        gap: 15px; 
        padding: 15px; 
    }
    .badge { border-bottom: none; padding-bottom: 0; }
    .badge:last-child { border-bottom: none; padding-bottom: 0; }

    /* Suppression de la bordure et des marges pour les avis */
    .reviews-wrapper {
        border-top: none;
        padding-top: 0;
        margin-top: 0;
    }
}

@media (max-width: 480px) {
    .product-page { padding: 0 12px; margin-top: 10px; }
    .product-title { font-size: 1.4rem; }
    /* Note: j'ai supprimé le max-height sur carousel-main-view ici car il est géré par la règle précédente */
}