/**
 * SÉLECTEUR DE LANGUE — styles additionnels uniquement
 * Ne modifie PAS css/style.css — ajoute uniquement les styles du switcher de langue.
 * Responsive : adapté mobile, tablette et desktop.
 */

/* =====================================================
   SWITCHER — STRUCTURE DE BASE
   ===================================================== */
.lang-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 16px;
    flex-shrink: 0;
}

.lang-current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #888;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 5px 10px;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    text-decoration: none;
    background: transparent;
    transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
    white-space: nowrap;
    line-height: 1;
}

.lang-current:hover,
.lang-switcher:focus-within .lang-current,
.lang-switcher.is-open .lang-current {
    border-color: #D4AF37;
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.05);
}

.lang-flag {
    font-size: 15px;
    line-height: 1;
    display: inline-block;
}

.lang-arrow {
    font-size: 9px;
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.lang-switcher.is-open .lang-arrow,
.lang-switcher:focus-within .lang-arrow {
    transform: rotate(180deg);
}

/* =====================================================
   DROPDOWN — DESKTOP
   ===================================================== */
.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;            /* Commence exactement sous le bouton — pas de gap */
    right: 0;
    /* Pont invisible : 6px de padding-top pour combler le gap visuel
       sans perdre le survol entre le bouton et la liste */
    padding-top: 6px;
    z-index: 9999;
    /* Largeur min pour que les items soient lisibles */
    min-width: 165px;
}

/* Contenu visuel du dropdown dans un sous-conteneur */
.lang-dropdown-inner {
    background: #0f0f0f;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
    scrollbar-width: thin;
    scrollbar-color: #2a2a2a #0f0f0f;
}

.lang-dropdown-inner::-webkit-scrollbar { width: 4px; }
.lang-dropdown-inner::-webkit-scrollbar-track { background: #0f0f0f; }
.lang-dropdown-inner::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

/* Ouverture via hover CSS (desktop) ou classe JS .is-open */
.lang-switcher:hover .lang-dropdown,
.lang-switcher:focus-within .lang-dropdown,
.lang-switcher.is-open .lang-dropdown {
    display: block;
    animation: langFadeIn 0.15s ease;
}

@keyframes langFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lang-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: #888;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background 0.15s, color 0.15s;
    border-bottom: 1px solid #1a1a1a;
}

.lang-dropdown a:last-child {
    border-bottom: none;
}

.lang-dropdown a:hover,
.lang-dropdown a.lang-active {
    background: #1a1a1a;
    color: #D4AF37;
}

.lang-dropdown a .lang-flag {
    font-size: 17px;
    flex-shrink: 0;
}

/* =====================================================
   RTL SUPPORT (Arabe)
   ===================================================== */
[dir="rtl"] .lang-switcher {
    margin-left: 0;
    margin-right: 16px;
}

[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

/* =====================================================
   RESPONSIVE — TABLETTE (<= 900px)
   ===================================================== */
@media (max-width: 900px) {
    .lang-switcher {
        margin-left: 10px;
    }

    .lang-current {
        padding: 5px 8px;
        font-size: 10px;
    }

    /* Masquer le nom de la langue et ne garder que le drapeau sur tablette */
    .lang-current .lang-name {
        display: none;
    }

    .lang-dropdown {
        min-width: 140px;
    }
}

/* =====================================================
   RESPONSIVE — MOBILE (<= 600px)
   ===================================================== */
@media (max-width: 600px) {
    .lang-switcher {
        margin-left: 0;
    }

    /* Sur mobile : bottom sheet fixe */
    .lang-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-width: 100%;
        max-height: 55vh;
        padding-top: 0;  /* Pas de pont invisible sur mobile */
    }

    .lang-dropdown-inner {
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 1px solid #2a2a2a;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.8);
        max-height: 55vh;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: auto;
    }

    .lang-dropdown a {
        width: 50%;
        border-bottom: 1px solid #1a1a1a;
        border-right: 1px solid #1a1a1a;
        box-sizing: border-box;
        padding: 12px 14px;
        font-size: 13px;
    }

    /* Enlever la bordure droite sur la 2ème colonne */
    .lang-dropdown a:nth-child(2n) {
        border-right: none;
    }

    /* Bouton switcher mobile */
    .lang-current {
        padding: 7px 10px;
        font-size: 13px;
        border-radius: 6px;
    }

    .lang-current .lang-name,
    .lang-current .lang-arrow {
        display: none;
    }
}

/* =====================================================
   OVERLAY MOBILE (fermer le dropdown en cliquant en dehors)
   ===================================================== */
.lang-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,0.5);
}

.lang-overlay.active { display: block; }
