/**
 * ProductsOptions v3.0 — Front-Office CSS
 * Accordéon intelligent, public 50+, premium et sobre.
 *
 * Convention : préfixe po- sur toutes les classes.
 * Couleurs via CSS custom properties (overridables par le thème SCSS).
 */

/* ================================================================
   VARIABLES (overridables par le thème)
   ================================================================ */

:root {
    --po-primary: #0b5e84;
    --po-primary-dark: #094b6a;
    --po-secondary: #00b0f1;
    --po-text: #1a1a1a;
    --po-text-muted: #555;
    --po-border: #ddd;
    --po-bg: #fff;
    --po-bg-light: #f7f7f7;
    --po-bg-hover: #f0f0f0;
    --po-radius: 4px;
    --po-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --po-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --po-transition: 0.3s ease;
}

/* ================================================================
   LAYOUT PRINCIPAL
   ================================================================ */

.po-configurator {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-top: 16px;
}

.po-main {
    flex: 1;
    min-width: 0;
}

/* ================================================================
   TITRE SECTION
   ================================================================ */

/* ================================================================
   GROUPE D'OPTIONS (carte)
   ================================================================ */

.po-group {
    background: var(--po-bg);
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius);
    margin-bottom: 12px;
    box-shadow: var(--po-shadow);
    overflow: hidden;
    transition: box-shadow var(--po-transition);
}

.po-group:hover {
    box-shadow: var(--po-shadow-lg);
}

/* Header du groupe — cliquable */
.po-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    cursor: pointer;
    background: var(--po-bg);
    border-bottom: 1px solid transparent;
    border-left: 3px solid transparent;
    transition: background var(--po-transition), border-color var(--po-transition);
    user-select: none;
}

.po-group-header:hover {
    background: var(--po-bg-hover);
    border-left-color: var(--po-primary);
}

.po-group.is-open .po-group-header {
    border-bottom-color: var(--po-border);
    border-left-color: var(--po-primary);
    background: var(--po-bg-light);
}

.po-group.is-open {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Phrase d'introduction */
.po-intro {
    font-size: 1rem;
    color: var(--po-text-muted);
    margin-bottom: 20px;
    padding: 0 4px;
    line-height: 1.5;
}

/* Flash feedback quand une option est ajoutée */
@keyframes po-flash {
    0% { background: var(--po-bg); }
    30% { background: rgba(98, 170, 46, 0.12); }
    100% { background: var(--po-bg); }
}
.po-group-flash .po-group-header {
    animation: po-flash 0.6s ease;
}

.po-group-img {
    flex-shrink: 0;
    width: 35px;
    height: 35px;
    margin-right: 12px;
    border-radius: 6px;
    overflow: hidden;
}
.po-group-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.po-group-header-left {
    flex: 1;
    min-width: 0;
}

.po-group-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--po-text);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.po-group-subtitle {
    font-size: 0.9rem;
    color: var(--po-text-muted);
    margin: 0;
    line-height: 1.4;
}

.po-group.is-open .po-group-subtitle {
    display: none;
}

.po-group-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: 16px;
}

/* Statut du groupe */
.po-group-status {
    font-size: 0.9rem;
    color: var(--po-text-muted);
    white-space: nowrap;
}

.po-group.has-selection .po-group-status {
    color: var(--po-primary);
    font-weight: 600;
}

/* Chevron */
.po-group-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1rem;
    color: var(--po-text-muted);
    background: var(--po-bg-light);
    border: 1px solid var(--po-border);
    border-radius: 50%;
    transition: transform var(--po-transition), background var(--po-transition), color var(--po-transition);
}

.po-group-header:hover .po-group-chevron {
    background: var(--po-primary);
    color: #fff;
    border-color: var(--po-primary);
}

.po-group.is-open .po-group-chevron {
    transform: rotate(180deg);
}

/* Body du groupe (repliable) */
.po-group-body {
    display: none;
    padding: 8px 0;
    background: var(--po-bg-light);
}

.po-group.is-open .po-group-body {
    display: block;
}

/* ================================================================
   SOUS-TITRE OPTION (niveau intermédiaire dans un groupe)
   ================================================================ */
.po-option-subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--po-primary);
    padding: 10px 20px 4px;
    border-bottom: 1px solid var(--po-border);
    margin-bottom: 0;
    display: flex;
    align-items: center;
}
/* Image miniature sur les sous-titres d'option */
.po-sub-img {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 8px;
    flex-shrink: 0;
}
/* Sous-accordéon : subtitle cliquable */
.po-sub-toggle {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    transition: background-color 0.15s;
}
.po-sub-toggle:hover {
    background: var(--po-bg-hover);
}
.po-sub-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--po-text-muted, #888);
}
.po-sub-chevron {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}
.po-sub-toggle.is-sub-open .po-sub-chevron {
    transform: rotate(180deg);
}
/* Corps du sous-accordéon */
.po-sub-body {
    overflow: hidden;
}
.po-sub-collapsed {
    display: none;
}

/* ================================================================
   LIGNE OPTION (produit dans un groupe)
   ================================================================ */

.po-option {
    display: grid;
    grid-template-columns: 70px 1fr auto auto;
    gap: 16px;
    padding: 20px 24px;
    align-items: center;
    border-bottom: 1px solid var(--po-border);
    background: var(--po-bg);
    transition: background var(--po-transition);
}

.po-option:last-child {
    border-bottom: none;
}

.po-option:hover {
    background: var(--po-bg-light);
}

/* Image */
.po-option-img {
    width: 70px;
    height: 70px;
    overflow: hidden;
    border-radius: var(--po-radius);
    border: 1px solid var(--po-border);
    flex-shrink: 0;
    background: var(--po-bg-light);
}

.po-option-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Infos */
.po-option-info {
    min-width: 0;
}

.po-option-name {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--po-text);
    line-height: 1.3;
    margin-bottom: 4px;
}

.po-option-detail-btn {
    display: inline-block;
    background: none;
    border: 1px solid var(--po-secondary);
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 0.9rem;
    color: var(--po-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: color var(--po-transition), background var(--po-transition);
    margin-top: 4px;
}

.po-option-detail-btn::before {
    content: "ℹ ";
}

.po-option-detail-btn:hover {
    color: #fff;
    background: var(--po-secondary);
}

/* Prix */
.po-option-price {
    text-align: right;
    white-space: nowrap;
}

.po-option-price-ttc {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--po-primary);
}

.po-option-price-ht {
    display: block;
    font-size: 0.8rem;
    color: var(--po-text-muted);
    margin-top: 2px;
}

/* Quantité */
.po-option-qty {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.po-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--po-text);
    background: var(--po-bg-light);
    border: 1px solid var(--po-border);
    cursor: pointer;
    transition: background var(--po-transition), color var(--po-transition);
    user-select: none;
    line-height: 1;
}

.po-qty-btn:hover {
    background: var(--po-primary);
    color: #fff;
    border-color: var(--po-primary);
}

.po-qty-btn:active {
    background: var(--po-primary-dark);
}

.po-qty-btn.po-qty-minus {
    border-radius: var(--po-radius) 0 0 var(--po-radius);
    border-right: none;
}

.po-qty-btn.po-qty-plus {
    border-radius: 0 var(--po-radius) var(--po-radius) 0;
    border-left: none;
}

.po-qty-input {
    width: 52px;
    height: 44px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid var(--po-border);
    border-radius: 0;
    -moz-appearance: textfield;
    background: var(--po-bg);
    color: var(--po-text);
}

.po-qty-input::-webkit-outer-spin-button,
.po-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.po-qty-input:focus {
    outline: none;
    border-color: var(--po-primary);
    box-shadow: 0 0 0 2px rgba(98, 170, 46, 0.2);
}

.po-qty-input:disabled {
    background: #eee;
    color: #999;
}

/* Select caché (données pour le panier) */
.po-option-select-hidden {
    display: none;
}

/* Stock indicator */
.po-stock {
    font-size: 0.8rem;
    margin-top: 4px;
    text-align: center;
}

.po-stock.in-stock {
    color: var(--po-primary);
}

.po-stock.low-stock {
    color: #e67e22;
}

.po-stock.out-of-stock {
    color: #c0392b;
    font-weight: 600;
}

/* ================================================================
   PANEL DÉTAILS (repliable sous l'option)
   ================================================================ */

.po-option-detail-panel {
    grid-column: 1 / -1;
    padding: 16px 20px;
    background: var(--po-bg-light);
    border-top: 1px solid var(--po-border);
    border-radius: 0 0 var(--po-radius) var(--po-radius);
    margin-top: 8px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--po-text);
}

.po-option-detail-panel h3,
.po-option-detail-panel h4 {
    color: var(--po-primary);
    font-size: 1rem;
    font-weight: 700;
    margin: 12px 0 6px 0;
}

.po-option-detail-panel h3:first-child,
.po-option-detail-panel h4:first-child {
    margin-top: 0;
}

.po-option-detail-panel p {
    margin: 0 0 8px 0;
}

.po-option-detail-panel strong {
    color: var(--po-text);
}

/* ================================================================
   WARNINGS
   ================================================================ */

.po-warnings {
    padding: 12px 16px;
}

.po-warning-item {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--po-radius);
    padding: 10px 16px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #856404;
    cursor: pointer;
    transition: background var(--po-transition);
}

.po-warning-item:hover {
    background: #ffe8a1;
}

/* ================================================================
   RÉCAPITULATIF STICKY (desktop)
   ================================================================ */

.po-summary {
    width: 320px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    background: var(--po-bg);
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius);
    box-shadow: var(--po-shadow);
    overflow: hidden;
}

.po-summary-header {
    background: var(--po-primary);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 16px 20px;
    text-align: center;
}

.po-summary-body {
    padding: 16px 20px;
}

.po-summary-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    font-size: 0.95rem;
    color: var(--po-text);
}

.po-summary-line-label {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}

.po-summary-line-price {
    font-weight: 600;
    white-space: nowrap;
}

.po-summary-base {
    border-bottom: 1px solid var(--po-border);
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.po-summary-options {
    min-height: 20px;
    margin-bottom: 8px;
}

.po-summary-options:empty::after {
    content: "Aucune option sélectionnée";
    color: var(--po-text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

.po-summary-divider {
    height: 1px;
    background: var(--po-border);
    margin: 8px 0;
}

.po-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 16px;
    margin: 12px -20px 0;
    background: var(--po-bg-light);
    border-top: 2px solid var(--po-primary);
}

.po-summary-total-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--po-text);
}

.po-summary-total-price {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--po-primary);
}

.po-summary-total-ht {
    text-align: right;
    font-size: 0.8rem;
    color: var(--po-text-muted);
    margin-bottom: 16px;
}

/* CTA principal — reprend les couleurs du bouton natif #add-to-cart */
.po-cta {
    display: block;
    width: 100%;
    padding: 16px 24px;
    font-size: 1.15rem;
    font-weight: 900;
    color: #ffffff;
    background-color: #29b9ad;
    border: 2px solid #29b9ad;
    border-radius: var(--po-radius);
    cursor: pointer;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 1px 1px rgba(0, 0, 0, 0.2);
    transition: background var(--po-transition), box-shadow var(--po-transition);
    margin: 0 20px 20px 20px;
    width: calc(100% - 40px);
}

.po-cta:hover {
    background-color: #12ccb4;
    border-color: #12ccb4;
    color: #ffffff;
    box-shadow: var(--po-shadow-lg);
}

.po-cta:active {
    transform: scale(0.98);
}

.po-cta:disabled {
    background: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* ================================================================
   BARRE MOBILE (sticky bottom)
   ================================================================ */

.po-mobile-bar {
    display: none;
}

/* ================================================================
   SCROLL-TO CTA (bouton dans fiche produit)
   ================================================================ */

.po-scroll-to-options {
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--po-primary);
    background: transparent;
    border: 2px solid var(--po-primary);
    border-radius: var(--po-radius);
    text-decoration: none;
    transition: all var(--po-transition);
}

.po-scroll-to-options:hover {
    background: var(--po-primary);
    color: #fff;
}

/* ================================================================
   QUICK VIEW BADGE
   ================================================================ */

.po-quickview-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--po-bg-light);
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius);
    margin-top: 8px;
    font-size: 0.9rem;
}

.po-quickview-badge a {
    color: var(--po-primary);
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}

/* ================================================================
   RESPONSIVE — TABLETTE (< 992px)
   ================================================================ */

@media (max-width: 991px) {
    .po-configurator {
        flex-direction: column;
    }

    .po-summary {
        display: none;
    }

    .po-mobile-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--po-bg);
        border-top: 2px solid var(--po-border);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
        padding: 12px 16px;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .po-mobile-total {
        font-size: 1.4rem;
        font-weight: 800;
        color: var(--po-primary);
        white-space: nowrap;
    }

    .po-mobile-cta {
        padding: 12px 24px;
        font-size: 1rem;
        font-weight: 900;
        color: #ffffff;
        background-color: #29b9ad;
        border: 2px solid #29b9ad;
        border-radius: var(--po-radius);
        cursor: pointer;
        white-space: nowrap;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 1px 1px 1px rgba(0, 0, 0, 0.2);
        transition: background var(--po-transition);
    }

    .po-mobile-cta:hover {
        background-color: #12ccb4;
        border-color: #12ccb4;
        color: #ffffff;
    }

    /* Padding bottom pour ne pas cacher le contenu sous la barre */
    .po-configurator {
        padding-bottom: 80px;
    }
}

/* ================================================================
   RESPONSIVE — MOBILE (< 768px)
   ================================================================ */

@media (max-width: 767px) {
    .po-group-header {
        padding: 16px;
    }

    .po-group-title {
        font-size: 1.05rem;
    }

    .po-option {
        grid-template-columns: 60px 1fr;
        gap: 10px;
        padding: 12px 16px;
    }

    .po-option-img {
        width: 60px;
        height: 60px;
    }

    .po-option-info {
        grid-column: 2;
    }

    .po-option-price {
        grid-column: 1 / -1;
        text-align: left;
        display: flex;
        align-items: baseline;
        gap: 8px;
    }

    .po-option-price-ttc {
        font-size: 1.1rem;
    }

    .po-option-qty {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .po-option-detail-panel {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .po-mobile-bar {
        padding: 10px 12px;
    }

    .po-mobile-total {
        font-size: 1.2rem;
    }

    .po-mobile-cta {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

}

/* ================================================================
   UTILITAIRES
   ================================================================ */

.po-hidden {
    display: none !important;
}

.po-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
