/* =============================================================================
   French Flair Embroidery — Frontend customizer
   ============================================================================= */

/* =========================================================================
   SÉLECTEUR DE MATIÈRE INTÉRIEURE
   Rendu en dehors de #ffe-customizer → redéfinition des variables de design.
   Les deux options sont affichées côte à côte (grille 2 colonnes).
   Chaque option réutilise .ffe-option-row / .ffe-option-label / .ffe-option-box
   pour un rendu identique aux checkboxes du plugin.
   ========================================================================= */
.ffe-material-selector {
    --ffe-border:       rgba(255, 255, 255, 0.15);
    --ffe-bg:           rgba(255, 255, 255, 0.05);
    --ffe-text:         #ffffff;
    --ffe-muted:        rgba(255, 255, 255, 0.55);
    --ffe-accent:       #ffffff;
    --ffe-radius:       8px;
    --ffe-transition:   200ms ease;

    margin: 0 0 20px;
}
.ffe-material-selector__title {
    font-size: 13px;
    font-weight: 500;
    color: var(--ffe-text);
    margin: 0 0 10px;
}

/* Grille 2 colonnes — les deux options côte à côte */
.ffe-material-rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Miniature photo */
.ffe-material-thumb {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Nom + description empilés verticalement dans .ffe-option-text */
.ffe-material-selector .ffe-option-text {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}
.ffe-material-desc {
    font-size: 11px;
    font-weight: 400;
    color: var(--ffe-muted);
    line-height: 1.35;
}

@media (max-width: 480px) {
    .ffe-material-rows {
        grid-template-columns: 1fr;
    }
    .ffe-material-thumb {
        width: 44px;
        height: 44px;
    }
}

/* ---- Polices personnalisées ------------------------------------------------
   POLICES TEMPORAIRES : Dancing Script (cursive) + Nunito (sans-serif)
   chargées via Google Fonts dans class-ffe-frontend.php.

   Pour remplacer par vos propres polices :
     1. Déposer les fichiers .woff2 dans assets/fonts/ :
          - ffe-cursive.woff2   (police cursive)
          - ffe-sans.woff2      (police sans-serif)
     2. Décommenter les @font-face ci-dessous
     3. Supprimer le wp_enqueue_style 'ffe-temp-fonts' dans class-ffe-frontend.php
   --------------------------------------------------------------------------- */

/*
@font-face {
    font-family: 'FFE Cursive';
    src: url('../fonts/ffe-cursive.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'FFE Sans';
    src: url('../fonts/ffe-sans.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
*/

/* Alias vers les polices Google Fonts temporaires */
@font-face {
    font-family: 'FFE Cursive';
    src: local('Dancing Script');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'FFE Sans';
    src: local('Heebo');
    font-weight: normal;
    font-style: normal;
}

/* ---- Variables de design — thème sombre (fond Divi dark) ------------------*/
.ffe-customizer {
    --ffe-cream:        rgba(255, 255, 255, 0.10);
    --ffe-border:       rgba(255, 255, 255, 0.15);
    --ffe-bg:           rgba(255, 255, 255, 0.05);
    --ffe-text:         #ffffff;
    --ffe-muted:        rgba(255, 255, 255, 0.55);
    --ffe-accent:       #ffffff;
    --ffe-radius:       8px;
    --ffe-transition:   200ms ease;

    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 24px 0;
    font-family: inherit;
    color: var(--ffe-text);
}

/* Masquage par classe — plus fiable que l'attribut [hidden] face à Divi/WooCommerce */
.ffe-customizer .ffe-is-hidden {
    display: none !important;
}

/* =========================================================================
   OPTION BRODERIE — toggle d'activation client
   ========================================================================= */
.ffe-option-row {
    background: var(--ffe-bg);
    border: 1px solid var(--ffe-border);
    border-radius: var(--ffe-radius);
    padding: 14px 16px;
}
.ffe-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--ffe-text);
}
/* Cache la checkbox native */
.ffe-option-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
/* Checkbox custom */
.ffe-option-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ffe-transition);
}
.ffe-option-box::after {
    content: '';
    display: block;
    width: 13px;
    height: 6px;
    border-left: 3px solid #23437c;
    border-bottom: 3px solid #23437c;
    transform: rotate(-45deg) translateY(-2px) translateX(2px);
    transition: opacity var(--ffe-transition);
    opacity: 0;
}
.ffe-option-checkbox:checked ~ .ffe-option-box {
    background: var(--ffe-accent);
    border-color: var(--ffe-accent);
}
.ffe-option-checkbox:checked ~ .ffe-option-box::after {
    opacity: 1;
}
.ffe-option-checkbox:focus-visible ~ .ffe-option-box {
    outline: 2px solid var(--ffe-accent);
    outline-offset: 2px;
}
.ffe-option-text {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.ffe-option-price {
    font-size: 12px;
    font-weight: 400;
    color: var(--ffe-accent);
    background: var(--ffe-cream);
    border: 1px solid var(--ffe-border);
    border-radius: 10px;
    padding: 1px 8px;
}

/* Contenu masqué par défaut — révélé par JS */
.ffe-customizer-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* =========================================================================
   CARROUSEL
   ========================================================================= */
.ffe-carousel {
    position: relative;
}
.ffe-carousel-stage {
    position: relative;
    background: var(--ffe-bg);
    border: 1px solid var(--ffe-border);
    border-radius: var(--ffe-radius);
    overflow: hidden;
    aspect-ratio: 1 / 1;
    user-select: none;
    touch-action: pan-y;
}

/* Slides */
.ffe-carousel-slides {
    position: relative;
    width: 100%;
    height: 100%;
}
.ffe-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--ffe-transition);
    pointer-events: none;
}
.ffe-slide.is-active {
    opacity: 1;
    pointer-events: all;
}
.ffe-slide.is-entering {
    opacity: 0;
}

/* Image produit */
.ffe-slide__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Canvas broderie */
.ffe-slide__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--ffe-transition);
}
.ffe-slide__canvas.is-visible {
    opacity: 1;
}

/* Flèches navigation */
.ffe-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255,255,255,.85);
    border: 1px solid var(--ffe-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--ffe-transition), opacity var(--ffe-transition);
    padding: 0;
}
.ffe-arrow:hover {
    background: #fff;
}
.ffe-arrow:disabled,
.ffe-arrow[hidden] {
    opacity: 0;
    pointer-events: none;
}
.ffe-arrow svg {
    width: 18px;
    height: 18px;
    stroke: var(--ffe-text);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ffe-arrow--prev { left: 8px; }
.ffe-arrow--next { right: 8px; }

/* Dots */
.ffe-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}
.ffe-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ffe-border);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background var(--ffe-transition), transform var(--ffe-transition);
}
.ffe-dot.is-active {
    background: var(--ffe-accent);
    transform: scale(1.3);
}
.ffe-dot:focus-visible {
    outline: 2px solid var(--ffe-accent);
    outline-offset: 2px;
}

/* Toggle aperçu — retiré de l'interface */
.ffe-preview-toggle {
    display: none;
}
.ffe-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--ffe-transition);
    border: none;
}
.ffe-btn--ghost {
    background: transparent;
    border: 1px solid var(--ffe-accent);
    color: var(--ffe-accent);
}
.ffe-btn--ghost:hover {
    background: var(--ffe-cream);
}
.ffe-btn--ghost.is-active {
    background: var(--ffe-accent);
    color: rgba(0, 0, 0, 0.85);
}

/* =========================================================================
   FORMULAIRE
   ========================================================================= */
.ffe-form__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--ffe-text);
}
.ffe-field {
    margin-bottom: 14px;
}
.ffe-field__label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--ffe-text);
}
.ffe-label--inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.ffe-field--radio {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.ffe-field--radio span {
    font-size: 13px;
    font-weight: 500;
    margin-right: 4px;
}
.ffe-field--radio label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* Input texte */
.ffe-input-wrap {
    position: relative;
}
.ffe-text-input {
    width: 100%;
    padding: 9px 12px;
    padding-right: 90px;
    border: 1px solid var(--ffe-border);
    border-radius: var(--ffe-radius);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
    transition: border-color var(--ffe-transition), box-shadow var(--ffe-transition);
    box-sizing: border-box;
    outline: none;
}
.ffe-text-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}
.ffe-text-input:focus {
    border-color: var(--ffe-accent);
    box-shadow: 0 0 0 3px rgba(200, 144, 74, .20);
}
.ffe-text-input:disabled {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.30);
}
.ffe-counter {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #23437c;
    pointer-events: none;
    white-space: nowrap;
}
.ffe-counter.is-warning .ffe-counter__val {
    color: #c0392b;
    font-weight: 700;
}

/* Bloc pied désactivé */
.ffe-foot-block.is-disabled {
    opacity: .4;
    pointer-events: none;
}

/* Sélecteur typographie */
.ffe-typo-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.ffe-typo-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 10px 16px;
    border: 1px solid var(--ffe-border);
    border-radius: var(--ffe-radius);
    transition: all var(--ffe-transition);
    background: rgba(255, 255, 255, 0.06);
    min-width: 90px;
    text-align: center;
}
.ffe-typo-option:has(input:checked) {
    border-color: var(--ffe-accent);
    background: rgba(255, 255, 255, 0.12);
}
.ffe-typo-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.ffe-typo-preview {
    font-size: 22px;
    color: var(--ffe-text);
    line-height: 1;
}
.ffe-typo-preview--cursive {
    font-family: 'Dancing Script', 'FFE Cursive', cursive;
}
.ffe-typo-preview--sans {
    font-family: 'Heebo', 'FFE Sans', sans-serif;
}
.ffe-typo-name {
    font-size: 11px;
    color: var(--ffe-muted);
}

/* Surcoût */
.ffe-price-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--ffe-cream);
    border: 1px solid var(--ffe-border);
    border-radius: var(--ffe-radius);
    margin-top: 4px;
}
.ffe-price-label {
    font-size: 13px;
    font-weight: 500;
}
.ffe-price-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ffe-accent);
}

/* =========================================================================
   SOUS-TOTAL
   ========================================================================= */
.ffe-subtotal {
    background: var(--ffe-cream);
    border: 2px solid var(--ffe-accent);
    border-radius: var(--ffe-radius);
    overflow: hidden;
    margin-top: 4px;
}
.ffe-subtotal__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-size: 13px;
    gap: 8px;
}
.ffe-subtotal__row--detail {
    background: rgba(255,255,255,.06);
    color: var(--ffe-muted);
    font-size: 12px;
    border-bottom: 1px solid var(--ffe-border);
    flex-wrap: wrap;
}
.ffe-subtotal__row--total {
    font-weight: 600;
    font-size: 14px;
}
.ffe-subtotal__amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--ffe-accent);
    white-space: nowrap;
}
.ffe-embroidery-notice {
    font-size: 11px;
    color: var(--ffe-muted);
    font-style: italic;
    line-height: 1.5;
    margin: 0;
    padding: 7px 14px 9px !important;
    border-top: 1px solid var(--ffe-border);
}

/* =========================================================================
   CARROUSEL DANS LA GALERIE WOOCOMMERCE (desktop ≥ 992 px)
   Le carrousel du plugin est injecté dans .woocommerce-product-gallery
   mais reste invisible par défaut. Il remplace la galerie WC uniquement
   quand la broderie est activée (classe ffe-embroidery-active).
   ========================================================================= */

/* Masquage galerie native via classe JS — compatible tous thèmes (Divi inclus) :
   ffe-hide-native ne touche pas les inline styles WC/Divi, évite le bug de
   restauration quand aucune variante n'est sélectionnée. */
.woocommerce-product-gallery.ffe-has-embroidery-preview.ffe-hide-native > *:not(.ffe-carousel--gallery) {
    display: none !important;
}

@media (min-width: 992px) {
    /* Par défaut : notre carrousel masqué, galerie WC visible normalement */
    .woocommerce-product-gallery.ffe-has-embroidery-preview .ffe-carousel--gallery {
        display: none;
    }

    /* Broderie cochée : afficher notre carrousel */
    .woocommerce-product-gallery.ffe-has-embroidery-preview.ffe-embroidery-active .ffe-carousel--gallery {
        display: block;
        width: 100%;
        margin: 0;
    }
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 768px) {
    .ffe-arrow {
        width: 30px;
        height: 30px;
    }
    .ffe-arrow svg {
        width: 14px;
        height: 14px;
    }
    .ffe-typo-options {
        gap: 8px;
    }
}

/* =========================================================================
   ACCESSIBILITÉ — focus visible
   ========================================================================= */
.ffe-text-input:focus-visible,
.ffe-arrow:focus-visible,
.ffe-btn:focus-visible,
.ffe-typo-option:focus-within {
    outline: 2px solid var(--ffe-accent);
    outline-offset: 2px;
}

/* =========================================================================
   GUIDE DES TAILLES — bouton déclencheur
   ========================================================================= */
.ffe-guide-trigger {
    text-align: right;
    margin-bottom: 15px;
}
.ffe-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 0;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    transition: color 200ms ease;
}
.ffe-guide-btn__icon {
    flex-shrink: 0;
    transition: opacity 200ms ease;
}
.ffe-guide-btn:hover {
    color: #ffffff;
}
.ffe-guide-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
    border-radius: 3px;
}

/* =========================================================================
   GUIDE DES TAILLES — overlay et modale
   ========================================================================= */
.ffe-guide-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}
.ffe-guide-overlay.is-open {
    opacity: 1;
    pointer-events: all;
}
body.ffe-guide-open {
    overflow: hidden;
}

.ffe-guide-modal {
    background: #ffffff;
    color: #1E2D5F;
    border-radius: 14px;
    max-width: 560px;
    width: 100%;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    transform: translateY(8px) scale(0.98);
    transition: transform 220ms ease;
}
.ffe-guide-overlay.is-open .ffe-guide-modal {
    transform: translateY(0) scale(1);
}

/* En-tête sticky — contient uniquement le bouton de fermeture */
.ffe-guide-modal__header {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px 6px;
    position: sticky;
    top: 0;
    background: #ffffff;
    border-radius: 14px 14px 0 0;
    z-index: 1;
}
.ffe-guide-modal__close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(30, 45, 95, 0.45);
    font-size: 22px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 200ms ease, background 200ms ease;
    flex-shrink: 0;
}
.ffe-guide-modal__close:hover {
    color: #1E2D5F;
    background: rgba(30, 45, 95, 0.07);
}
.ffe-guide-modal__close:focus-visible {
    outline: 2px solid #1E2D5F;
    outline-offset: 2px;
}

/* Corps */
.ffe-guide-modal__body {
    padding: 6px 24px 26px;
}

/* Texte d'introduction */
.ffe-guide-intro {
    font-size: 14px;
    color: #1E2D5F;
    line-height: 1.65;
    margin: 0 0 18px;
}

/* Tableau */
.ffe-guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 0 0 18px;
    border-radius: 8px;
    overflow: hidden;
}
.ffe-guide-table th {
    background: #1E2D5F;
    color: #ffffff;
    text-align: left;
    padding: 10px 14px 10px 24px !important;
    font-weight: 600;
    font-size: 13px;
}
.ffe-guide-table td {
    padding: 8px 14px 8px 24px !important;
    color: #1E2D5F;
    border-bottom: 1px solid rgba(30, 45, 95, 0.09);
}
.ffe-guide-table tbody tr:last-child td {
    border-bottom: none;
}
.ffe-guide-table tbody tr:nth-child(even) td {
    background: rgba(30, 45, 95, 0.04);
}

/* Note */
.ffe-guide-note {
    display: flex;
    align-items: center;
    background: rgba(30, 45, 95, 0.05);
    border-left: 3px solid #23437c;
    padding: 12px 15px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #1E2D5F;
    margin: 0;
    line-height: 1.55;
}

/* Responsive */
@media (max-width: 520px) {
    .ffe-guide-overlay {
        padding: 16px 12px;
        align-items: flex-end;
    }
    .ffe-guide-modal {
        border-radius: 14px 14px 0 0;
        max-height: 88vh;
        transform: translateY(16px);
    }
    .ffe-guide-modal__header {
        padding: 16px 16px 14px;
        border-radius: 14px 14px 0 0;
    }
    .ffe-guide-modal__body {
        padding: 16px 16px 22px;
    }
    .ffe-guide-table th,
    .ffe-guide-table td {
        padding: 8px 10px;
        font-size: 13px;
    }
}
