/* ============================================
   EXTRA PRODUCT OPTIONS - CUSTOM DESIGN 2026
   (Optimisé pour UX Mobile & Accessibilité)
   ============================================ */

/* --- 0. Utilitaires de Filtrage --- */
.tm-hidden-country {
    display: none !important;
}

/* --- 1. Conteneur Grille --- */
.tm-extra-product-options ul.tm-extra-product-options-checkbox {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
    gap: 0.75rem !important;
    padding: 1rem !important;
    background: #ffffff !important;
    border-radius: 1.5rem !important;
    border: 1px solid #e2e8f0 !important; /* Bordure plus subtile */
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    
    /* Scroll amélioré */
    max-height: 450px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain; /* Empêche de scroller la page parent */
    -webkit-overflow-scrolling: touch; /* Fluidité iOS */
    
    /* Style scrollbar fin */
    scrollbar-width: thin;
    scrollbar-color: #7C3AED #f1f5f9;
}

/* Scrollbar Webkit (Chrome/Safari) */
.tm-extra-product-options ul.tm-extra-product-options-checkbox::-webkit-scrollbar {
    width: 6px;
}
.tm-extra-product-options ul.tm-extra-product-options-checkbox::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}
.tm-extra-product-options ul.tm-extra-product-options-checkbox::-webkit-scrollbar-thumb {
    background-color: #7C3AED;
    border-radius: 3px;
}

/* --- 2. Item (LI) - La Carte --- */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap {
    display: flex !important;
    position: relative !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 54px !important; /* Hauteur tactile minimale */
    
    background: #ffffff !important;
    border: 2px solid #f1f5f9 !important;
    border-radius: 1rem !important;
    
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    /* Pour s'assurer que le contenu ne dépasse pas */
    overflow: hidden !important; 
    
    /* Optimisation mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* --- 3. État Actif (JS + CSS natif) --- */
/* Combinaison classe JS + sélecteur CSS moderne */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap.tc-active,
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap[data-manus-active="true"],
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap:has(input:checked) {
    background: linear-gradient(135deg, #7C3AED 0%, #EC4899 100%) !important;
    border-color: #7C3AED !important; /* Fallback couleur si border transparent bug */
    box-shadow: 0 8px 16px -4px rgba(124, 58, 237, 0.4) !important;
    transform: translateY(-2px) !important;
    z-index: 2 !important;
}

/* --- 4. Icône Check (Coche) --- */
/* Ajout d'une zone spécifique pour le check */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap::after {
    content: '\f00c';
    font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", FontAwesome, sans-serif !important; 
    font-weight: 900 !important;
    
    position: absolute !important;
    top: 6px !important;
    right: 8px !important;
    
    font-size: 0.75rem !important;
    line-height: 1 !important;
    color: #ffffff !important;
    
    /* Animation de l'apparition */
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Affichage icône quand actif */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap.tc-active::after,
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap:has(input:checked)::after {
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* --- 5. Inputs : Le masquage propre (Visually Hidden) --- */
/* NE JAMAIS utiliser display: none sur des inputs qu'on veut soumettre */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap input[type="checkbox"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    pointer-events: none !important; /* Empêche le clic direct sur l'input invisible */
}

/* Style de focus (pour accessibilité navigation clavier) */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap:focus-within {
    border-color: #7C3AED !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2) !important;
}

/* --- 6. Label & Textes --- */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0.75rem 0.5rem !important;
    cursor: pointer !important;
    z-index: 1 !important;
}

/* Texte spécifique */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap .tc-label-wrap {
    color: #64748b !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    word-break: break-word !important; /* Évite que les noms longs cassent la boite */
}

/* Couleur texte Actif */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap.tc-active .tc-label-wrap,
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap:has(input:checked) .tc-label-wrap {
    color: #ffffff !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- 7. États Hover --- */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap:not(.tc-active):not(:has(input:checked)):hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    transform: translateY(-1px) !important;
}

/* --- 8. Nettoyage Structure Interne Plugin --- */
/* Suppression des wrappers intermédiaires qui cassent souvent le flex/height */
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap .tmcp-field-wrap-inner,
.tm-extra-product-options ul.tm-extra-product-options-checkbox li.tmcp-field-wrap .tc-field-label-wrap {
    display: contents !important; /* Le contenu ignore ce wrapper et suit la grille parent */
}

.tc-input-wrap {
    display: none !important; /* Celui-ci peut être caché sans danger généralement */
}
/* ============================================
   DESIGN DES CHAMPS PERSONNALISÉS (SELECT, INPUT, TEXTAREA)
   ============================================ */

/* Conteneur global des options */
.tm-extra-product-options {
    padding: 1.5rem !important;
    background: #ffffff !important;
    border-radius: 2rem !important;
    border: 1px solid #f1f5f9 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.02) !important;
    margin-bottom: 2rem !important;
}

/* Titres des sections d'options */
.tm-extra-product-options .tm-epo-field-label {
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    margin-bottom: 0.75rem !important;
    display: block !important;
    letter-spacing: -0.01em !important;
}

/* Style des menus déroulants (Select) */
.tm-extra-product-options select.tmcp-select,
.tm-extra-product-options select.tmcp-selectmultiple {
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    background-color: #f8fafc !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 1.25rem !important;
    border: 2px solid #f1f5f9 !important;
    border-radius: 1rem !important;
    color: #475569 !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    appearance: none !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    margin-bottom: 1.25rem !important;
}

.tm-extra-product-options select.tmcp-select:focus,
.tm-extra-product-options select.tmcp-selectmultiple:focus {
    background-color: #ffffff !important;
    border-color: #7C3AED !important;
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1) !important;
    color: #1e293b !important;
}

/* Style des champs texte et textareas */
.tm-extra-product-options input.tmcp-textfield,
.tm-extra-product-options textarea.tmcp-textarea {
    width: 100% !important;
    padding: 0.85rem 1rem !important;
    background-color: #f8fafc !important;
    border: 2px solid #f1f5f9 !important;
    border-radius: 1rem !important;
    color: #1e293b !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    margin-bottom: 1.25rem !important;
}

.tm-extra-product-options input.tmcp-textfield:focus,
.tm-extra-product-options textarea.tmcp-textarea:focus {
    background-color: #ffffff !important;
    border-color: #7C3AED !important;
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1) !important;
}

/* Amélioration des labels requis */
.tm-extra-product-options .tm-epo-required {
    color: #ef4444 !important;
    margin-left: 4px !important;
}

/* Espacement entre les groupes d'options */
.tm-extra-product-options .tm-cell {
    margin-bottom: 1.5rem !important;
    padding: 0 !important;
}

/* Style spécifique pour le conteneur de recherche (Hybrid System) */
#country-hybrid-system {
    background: #f8fafc !important;
    padding: 1.25rem !important;
    border-radius: 1.5rem !important;
    border: 1px solid #f1f5f9 !important;
    margin-bottom: 1.5rem !important;
}

#country-search {
    border: 2px solid #e2e8f0 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) !important;
}

#country-search:focus {
    border-color: #7C3AED !important;
    background: #ffffff !important;
}

/* Boutons de région (Pills) */
.region-pill {
    font-size: 0.75rem !important;
    padding: 0.6rem 1.2rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.025em !important;
}

/* ============================================
   DESIGN DES MESSAGES D'ERREUR DE VALIDATION
   ============================================ */

/* Message d'erreur (Label généré par jQuery Validate) */
.tm-extra-product-options label.tm-error,
.tm-extra-product-options label.error,
.tc-invalid-message,
.tm-epo-field-label.tm-error {
    display: block !important;
    color: #ef4444 !important;
    background: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
    padding: 0.75rem 1rem !important;
    border-radius: 0.75rem !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    position: relative !important;
    animation: tcShake 0.4s cubic-bezier(.36,.07,.19,.97) both !important;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.05) !important;
}

/* Ajout d'une icône d'avertissement avant le message */
.tm-extra-product-options label.tm-error::before,
.tm-extra-product-options label.error::before {
    content: '\f06a' !important;
    font-family: 'Font Awesome 5 Free', 'Font Awesome 6 Free' !important;
    font-weight: 900 !important;
    margin-right: 8px !important;
    font-size: 0.9rem !important;
}

/* Style des champs en erreur */
.tm-extra-product-options .tm-error.tmcp-textfield,
.tm-extra-product-options .tm-error.tmcp-select,
.tm-extra-product-options .tm-error.tmcp-textarea,
.tm-extra-product-options select.error,
.tm-extra-product-options input.error {
    border-color: #fca5a5 !important;
    background-color: #fffafb !important;
}

.tm-extra-product-options .tm-error.tmcp-textfield:focus,
.tm-extra-product-options .tm-error.tmcp-select:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1) !important;
}

/* Animation de secousse pour attirer l'attention */
@keyframes tcShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Amélioration visuelle de l'astérisque requis */
.tm-epo-required {
    color: #ef4444 !important;
    font-weight: 900 !important;
    margin-left: 3px !important;
    font-size: 1.1em !important;
    text-decoration: none !important;
}
