/**
 * Styles pour les selects hiérarchiques personnalisés
 * VERSION GÉNÉRIQUE - S'applique automatiquement à tous les selects
 */

/* ==========================================================================
   1. Reset & Hide Original Selects - VERSION GÉNÉRIQUE
   ========================================================================== */

/* ✅ Masquer TOUS les selects transformés */
select.hierarchical-transformed {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ✅ Masquer TOUS les wrappers Bootstrap Select transformés */
.bootstrap-select.transformed-select {
    display: none !important;
}

/* ✅ Alternative pour navigateurs avec :has() */
.elementor-field-group:has(select.hierarchical-transformed) .bootstrap-select {
    display: none !important;
}

/* ==========================================================================
   2. Container Principal
   ========================================================================== */

.custom-hierarchical-select {
    position: relative;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   3. Header / Bouton Principal
   ========================================================================== */

.custom-select__head {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 40px 12px 16px;
    cursor: pointer;
    position: relative;
    transition: all 0.25s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    user-select: none;
}

.custom-select__head:hover {
    border-color: #b0b0b0;
    background: #fafafa;
}

.custom-select__head:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.custom-hierarchical-select.m--open .custom-select__head {
    border-color: #0066cc;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.custom-hierarchical-select.m--active .custom-select__head {
    background: #f0f7ff;
    border-color: #0066cc;
}

/* Icône chevron */
.custom-select__head .icon-chevron-down {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 18px;
    height: 18px;
    color: #666;
}

.custom-hierarchical-select.m--open .custom-select__head .icon-chevron-down {
    transform: translateY(-50%) rotate(180deg);
    color: #0066cc;
}

/* Label */
.custom-select__label {
    font-size: 15px;
    color: #2c3e50;
    font-weight: 500;
    line-height: 1.4;
}

.custom-select__count {
    color: #0066cc;
    font-weight: 700;
    margin-left: 4px;
}

/* ==========================================================================
   4. Dropdown Body
   ========================================================================== */

.custom-select__body {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    max-height: 420px;
    overflow-y: auto;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   5. Menu des Catégories
   ========================================================================== */

.custom-select__categories-menu {
    padding: 6px 0;
}

.custom-select__category {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.custom-select__category::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #0066cc;
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.custom-select__category:hover {
    background: #f8f9fa;
}

.custom-select__category:hover::before {
    transform: scaleX(1);
}

.custom-select__category:focus {
    outline: none;
    background: #f0f7ff;
}

.custom-select__category:last-child {
    border-bottom: none;
}

.custom-select__category__name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: #2c3e50;
    font-weight: 600;
}

.category-count {
    background: #0066cc;
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 24px;
    text-align: center;
}

.custom-select__category .icon {
    width: 18px;
    height: 18px;
    color: #999;
    transition: color 0.2s ease;
}

.custom-select__category:hover .icon {
    color: #0066cc;
}

/* ==========================================================================
   6. Container des Items
   ========================================================================== */

.custom-select__items-container {
    padding: 0;
}

/* Bouton Retour */
.custom-select__back {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #d0d0d0;
    font-weight: 700;
    color: #2c3e50;
    transition: all 0.2s ease;
    position: sticky;
    top: 0;
    z-index: 10;
}

.custom-select__back:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.custom-select__back:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px #0066cc;
}

.custom-select__back .icon {
    width: 18px;
    height: 18px;
    color: #0066cc;
}

/* ==========================================================================
   7. Liste des Items
   ========================================================================== */

.custom-select__items {
    padding: 6px 0;
}

.custom-select__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.custom-select__item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #0066cc;
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.custom-select__item:hover {
    background: #f8f9fa;
}

.custom-select__item:hover::before {
    transform: scaleX(1);
}

.custom-select__item:focus {
    outline: none;
    background: #f0f7ff;
}

.custom-select__item.m--inner-checked {
    background: #f0f7ff;
}

.custom-select__item__selector {
    flex: 1;
    min-width: 0;
}

/* Checkbox personnalisé */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox-like {
    width: 20px;
    height: 20px;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: #ffffff;
}

.checkbox-like:hover {
    border-color: #0066cc;
}

.checkbox-like.m--checked {
    background: #0066cc;
    border-color: #0066cc;
    animation: checkboxPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes checkboxPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.checkbox-like.m--checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 14px;
    color: #2c3e50;
    user-select: none;
    line-height: 1.4;
}

.custom-select__item.m--parent .checkbox-label {
    font-weight: 600;
}

/* Flèche pour items parents */
.custom-select__item__arrow {
    margin-left: 12px;
    color: #999;
    display: flex;
    align-items: center;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.custom-select__item__arrow:hover {
    background: rgba(0, 102, 204, 0.1);
    color: #0066cc;
}

.custom-select__item__arrow .icon {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   8. Icônes SVG
   ========================================================================== */

.icon {
    display: inline-block;
    fill: currentColor;
    pointer-events: none;
}

/* ==========================================================================
   9. Scrollbar Personnalisée
   ========================================================================== */

.custom-select__body::-webkit-scrollbar {
    width: 10px;
}

.custom-select__body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

.custom-select__body::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

.custom-select__body::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Firefox */
.custom-select__body {
    scrollbar-width: thin;
    scrollbar-color: #c0c0c0 #f1f1f1;
}

/* ==========================================================================
   10. États et Accessibilité
   ========================================================================== */

/* Focus visible pour accessibilité */
.custom-select__head:focus-visible,
.custom-select__category:focus-visible,
.custom-select__item:focus-visible,
.custom-select__back:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Disabled state */
.custom-hierarchical-select.m--disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   11. Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .custom-select__body {
        max-height: 360px;
    }

    .custom-select__head {
        padding: 11px 38px 11px 14px;
        min-height: 44px;
    }

    .custom-select__category,
    .custom-select__item {
        padding: 13px 16px;
    }

    .custom-select__back {
        padding: 13px 16px;
    }

    .custom-select__label {
        font-size: 14px;
    }

    .checkbox-like {
        width: 18px;
        height: 18px;
    }

    .checkbox-like.m--checked::after {
        left: 5px;
        top: 1px;
        width: 4px;
        height: 9px;
        border-width: 0 2px 2px 0;
    }
}

@media (max-width: 480px) {
    .custom-select__body {
        max-height: 300px;
    }

    .custom-select__category__name,
    .checkbox-label {
        font-size: 13px;
    }
}

/* ==========================================================================
   12. Print Styles
   ========================================================================== */

@media print {
    .custom-hierarchical-select {
        display: none !important;
    }
}

/* ==========================================================================
   13. Mode Debug (Optionnel)
   ========================================================================== */

body.hierarchical-select-debug .custom-hierarchical-select {
    outline: 2px dashed orange;
    outline-offset: 2px;
}

body.hierarchical-select-debug .custom-hierarchical-select::before {
    content: '🎯 Generic Mode';
    position: absolute;
    top: -20px;
    left: 0;
    background: orange;
    color: white;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 3px;
    z-index: 10000;
}


/**
 * Custom Reset Button Styles
 * À ajouter à hierarchical-select.css
 */

/* ==========================================================================
   Bouton Reset Custom
   ========================================================================== */

.custom-reset-btnn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 12px 20px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25) !important;
    position: relative !important;
    overflow: hidden !important;
}

.custom-reset-btnn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.35) !important;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
}

.custom-reset-btnn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.25) !important;
}

.custom-reset-btnn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4) !important;
}

/* Icône refresh */
.custom-reset-btnn .icon-refresh {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.custom-reset-btnn:hover .icon-refresh {
    transform: rotate(-180deg) !important;
}

/* Animation lors du reset */
.custom-reset-btnn.resetting .icon-refresh {
    animation: spin-reset 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@keyframes spin-reset {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(-360deg);
    }
}

/* Effet ripple au clic */
.custom-reset-btnn::before {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 0 !important;
    height: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.5) !important;
    transform: translate(-50%, -50%) !important;
    transition: width 0.6s, height 0.6s !important;
}

.custom-reset-btnn:active::before {
    width: 300px !important;
    height: 300px !important;
}

/* Texte du bouton */
.custom-reset-btnn span {
    position: relative !important;
    z-index: 1 !important;
}

/* ==========================================================================
   Variations de style (optionnel)
   ========================================================================== */

/* Version outline */
.custom-reset-btnn.outline {
    background: transparent !important;
    color: #667eea !important;
    border: 2px solid #667eea !important;
    box-shadow: none !important;
}

.custom-reset-btnn.outline:hover {
    background: #667eea !important;
    color: #ffffff !important;
    border-color: #667eea !important;
}

/* Version rouge (danger) */
.custom-reset-btnn.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.25) !important;
}

.custom-reset-btnn.danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.35) !important;
}

/* Version grise (neutre) */
.custom-reset-btnn.neutral {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%) !important;
    box-shadow: 0 4px 6px rgba(100, 116, 139, 0.25) !important;
}

.custom-reset-btnn.neutral:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%) !important;
    box-shadow: 0 6px 12px rgba(100, 116, 139, 0.35) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .custom-reset-btnn {
        padding: 10px 16px !important;
        font-size: 13px !important;
    }

    .custom-reset-btnn .icon-refresh {
        width: 16px !important;
        height: 16px !important;
    }
}

@media (max-width: 480px) {
    .custom-reset-btnn {
        padding: 8px 14px !important;
        font-size: 12px !important;
        gap: 6px !important;
    }

    .custom-reset-btnn .icon-refresh {
        width: 14px !important;
        height: 14px !important;
    }
}

/* ==========================================================================
   État disabled
   ========================================================================== */

.custom-reset-btnn:disabled,
.custom-reset-btnn.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* ==========================================================================
   Intégration avec le formulaire
   ========================================================================== */

/* S'assurer que le bouton s'intègre bien dans le layout du formulaire */
.elementor-field-type-submit .custom-reset-btnn,
.form-group .custom-reset-btnn {
    width: 100% !important;
}

/* Si dans une colonne Elementor */
.elementor-col-16 .custom-reset-btnn,
.elementor-col-25 .custom-reset-btnn {
    width: 100% !important;
}

/* ==========================================================================
   Debug Mode
   ========================================================================== */

body.hierarchical-select-debug .custom-reset-btnn {
    outline: 2px dashed orange !important;
    outline-offset: 2px !important;
}

body.hierarchical-select-debug .custom-reset-btnn::after {
    content: '🔄 Custom Reset' !important;
    position: absolute !important;
    bottom: -25px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: orange !important;
    color: white !important;
    padding: 2px 6px !important;
    font-size: 10px !important;
    font-weight: bold !important;
    border-radius: 3px !important;
    white-space: nowrap !important;
    z-index: 10000 !important;
}


