/*--------------------------------------------------------------
   JT Falang Language Switcher - style "module Joomla" custom
   Version : box unique + slide-down + sticky friendly
---------------------------------------------------------------*/

/* Bloc global = wrapper fixe dans le flux (pour ne plus décaler la navbar) */
.mod-jt-languageswitcher.jt-falang-switcher-custom {
    position: relative;
    display: inline-block;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Réserve une zone fixe dans la navbar */
    width: 42px;   /* même largeur que la box */
    height: 42px;  /* ≈ drapeau 32px + padding */
    z-index: 1100; /* pour être au-dessus du contenu si header sticky */
}

/* Conteneur interne avec l’ID select-container-XXX */
/* La box visible en permanence autour du switcher */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;                 /* occupe toute la zone du wrapper */
    display: inline-block;
    padding: 4px 4px 0px 4px;    /* léger ajustement vertical comme tu l’as fait */
    background: #ffffff;
    border-radius: 999px;
    border: 0.5px solid rgba(202, 219, 226, 0.9);
    box-shadow: 0px 3px 6px rgba(79, 104, 113, 0.25);
    box-sizing: border-box;
    transition: box-shadow 0.2s ease, border-radius 0.2s ease, padding 0.2s ease;
}

/* Base : effet visuel d’ouverture (sans hauteur spécifique) */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:hover {
    border-radius: 16px;
    box-shadow: 0px 7px 16px rgba(79, 104, 113, 0.35);
}

/* 1 langue en plus (2 langues au total) */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="1"]:hover {
    padding-bottom: 40px;
}

/* 2 langues en plus (3 langues au total) */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="2"]:hover {
    padding-bottom: 80px;
}

/* 3 langues en plus (4 langues au total) → ton cas actuel ≈ 120px */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="3"]:hover {
    padding-bottom: 120px;
}

/* 4 langues en plus (5 langues au total) */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="4"]:hover {
    padding-bottom: 160px;
}

/* 5 langues en plus (6 langues au total) */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"][data-lang-count="5"]:hover {
    padding-bottom: 200px;
}

/* Wrapper interne : bouton + dropdown */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* --------- Bouton langue active --------- */

.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Conteneur d’image générique */
.mod-jt-languageswitcher.jt-falang-switcher-custom .img-cover {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Drapeau actif = rond + ombre */
.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang .img-cover img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(79, 104, 113, 0.35);
    object-fit: cover;
    display: block;
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

/* Code langue optionnel (si show_codes = true) */
.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang .langname-code {
    margin-left: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #465663;
}

/* Petit effet au survol du bouton actif (desktop) */
.mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang:hover .img-cover img {
    transform: scale(1.05);
    box-shadow: 0px 0px 10px rgba(79, 104, 113, 0.45);
}

/* --------- Dropdown <ul> --------- */

/* Liste déroulante en slide-down animé */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul {
    position: absolute;
    top: 100%;              /* collé au bas du bouton */
    right: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: none;       /* on laisse la box principale gérer le fond */
    border-radius: 12px;
    min-width: 100%;
    box-sizing: border-box;
    z-index: 9999;

    /* Effet slide-down */
    max-height: 0;
    opacity: 0;
    overflow: visible;
    transform-origin: top center;
    transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
    pointer-events: none; /* pas cliquable quand fermé */
}

/* Ouverture quand on survole la box OU la liste elle-même */
.mod-jt-languageswitcher.jt-falang-switcher-custom [id^="select-container-"]:hover .mod-jt-languageswitcher__select > ul,
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul:hover {
    max-height: 200px;   /* à adapter si tu as beaucoup de langues */
    opacity: 1;
    pointer-events: auto;
}

/* Items de la liste */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li {
    padding: 4px 0;
    font-size: 14px;
}

/* Lien dans les items */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

/* Drapeaux dans la liste */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .img-cover {
    display: inline-flex;
    flex: 0 0 auto; /* le drapeau ne se fait pas écraser */
}

.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .img-cover img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(79, 104, 113, 0.3);
    object-fit: cover;
    display: block;
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
}

/* Code langue dans la liste */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .langname-code {
    margin-left: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #465663;
}

/* Hover item */
.mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li:hover {
    background: #f2f6f8;
}

/* --------- Tooltip (facultatif, mais propre) --------- */

[tooltip] {
    position: relative;
}

/* Base tooltip */
[tooltip]::before,
[tooltip]::after {
    position: absolute;
    display: none;
    opacity: 0;
    pointer-events: none;
    user-select: none;
    z-index: 100000;
    font-size: 12px;
    line-height: 1.2;
}

/* Triangle */
[tooltip]::before {
    content: "";
    border: 5px solid transparent;
}

/* Etiquette */
[tooltip]::after {
    content: attr(tooltip);
    background: #465663;
    color: #fff;
    font-family: Helvetica, Arial, sans-serif;
    border-radius: 4px;
    padding: 4px 6px;
    box-shadow: 0 0.8em 2em -0.6em rgba(0,0,0,0.4);
    white-space: nowrap;
}

/* Tooltip vers le bas */
[tooltip][flow^="down"]::before {
    top: 100%;
    left: 50%;
    border-top-width: 0;
    border-bottom-color: #465663;
    transform: translate(-50%, 0);
}

[tooltip][flow^="down"]::after {
    top: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, 0);
}

/* Tooltip vers le haut (si tu en as encore) */
[tooltip][flow^="up"]::before {
    bottom: 100%;
    left: 50%;
    border-bottom-width: 0;
    border-top-color: #465663;
    transform: translate(-50%, 0);
}

[tooltip][flow^="up"]::after {
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translate(-50%, 0);
}

/* Affichage au survol */
[tooltip]:hover::before,
[tooltip]:hover::after {
    display: block;
    animation: jt-tooltip-fade 180ms ease-out forwards;
}

/* Animation tooltip */
@keyframes jt-tooltip-fade {
    from {
        opacity: 0;
        transform: translate(-50%, 4px);
    }
    to {
        opacity: 0.9;
        transform: translate(-50%, 0);
    }
}

/* --------- Ajustement mobile ultra fin --------- */

@media (max-width: 640px) {

    /* Décalage ultra léger du drapeau actif pour un centrage parfait sur mobile */
    .mod-jt-languageswitcher.jt-falang-switcher-custom button.active-lang .img-cover img {
        transform: translate(0.8px, 0.8px);
    }

    /* Même correction pour les drapeaux du dropdown si tu veux un alignement identique */
    .mod-jt-languageswitcher.jt-falang-switcher-custom .mod-jt-languageswitcher__select > ul li .img-cover img {
        transform: translate(0.8px, 0.8px);
    }
}

/* Désactiver tous les tooltips sur mobile */
@media (max-width: 640px) {
    [tooltip]::before,
    [tooltip]::after {
        display: none !important;
    }
}
