/**
 * Dropdown de tri personnalisé
 */

/* Rendre le trigger cliquable */
.sorting-trigger {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Menu déroulant */
.sorting-dropdown-menu {
    position: fixed;
    background: #fff;
    border: 0.0625rem solid #e0e0e0;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: all 0.2s ease;
    z-index: 10000; /* Augmenté pour être au-dessus de tout */
    min-width: 15rem;
    max-width: 20rem;
}

.sorting-dropdown-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Sur mobile : centré avec transform */
@media (max-width: 768px) {
    .sorting-dropdown-menu.is-open {
        transform: translate(-50%, -50%) !important;
    }
}

.sorting-dropdown-menu__inner {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    max-height: 70vh; /* Limite la hauteur sur mobile */
    overflow-y: auto;
}

/* Items du menu */
.sorting-dropdown-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    font-size: 0.875rem;
    font-family: 'Montserrat', sans-serif;
    border-radius: 0.375rem;
    white-space: nowrap;
    transition: background 0.15s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Sur mobile : augmenter la zone de touch */
@media (max-width: 768px) {
    .sorting-dropdown-menu__item {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }
}

.sorting-dropdown-menu__item:hover {
    background: #f5f5f5;
}

.sorting-dropdown-menu__item:active {
    background: #e8e8e8;
}

.sorting-dropdown-menu__item.is-active {
    background: #f0f0f0;
    font-weight: 600;
}

/* Icône de check */
.sorting-dropdown-menu__check {
    flex-shrink: 0;
    color: #000;
}

/* Overlay pour fermer au clic en dehors */
.sorting-dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Fond semi-transparent sur mobile */
    z-index: 9999;
    display: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.sorting-dropdown-overlay.is-active {
    display: block;
}

/* Sur desktop : overlay transparent */
@media (min-width: 769px) {
    .sorting-dropdown-overlay {
        background: transparent;
    }
}