/* ============================================================
   Header Language Selector — presentation overrides
   ============================================================
   The control itself is rendered by the Atul WebGenie plugin
   (LPPT_Language_Switcher). The plugin styles it as a FLOATING pill:
   position:fixed; bottom:20px; left:20px, with an upward dropdown.

   These rules re-home that same control inside .ail-header-actions so it
   reads as a native header icon, matching the bell / profile / heart
   cluster (icon-only, 16px gap, var(--header-text), sticky header).

   The plugin's own stylesheet is NOT modified. This file is enqueued after
   it (wp_enqueue_scripts priority 21) and wins on load order + specificity.
   ============================================================ */

/* ---- Wrapper: sits in the flex row like any other header action ---- */
.ail-hdr-lang {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
}

/* ---- Un-float the plugin container ----
   `bottom` carries !important because the theme footer previously forced a
   floating offset; the declaration is kept defensively so any residual
   floating-era rule (from cache, a child theme or a customiser snippet) can
   never lift the header control out of alignment. */
.ail-hdr-lang .lppt-lang-switcher {
    position: relative;
    inset: auto;
    bottom: auto !important;
    left: auto;
    right: auto;
    top: auto;
    /* The header shell already owns z-index:1000; stay modest inside it. */
    z-index: 20;
    font-family: inherit;
}

/* ---- Trigger: icon-only, matches the neighbouring header icons ----
   The label is intentionally hidden: every sibling control (heart, bell,
   profile, hamburger) is icon-only, and a variable-width language name
   would shift the header layout each time the language changes. */
.ail-hdr-lang .lppt-lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    min-height: 34px;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid transparent;
    border-radius: 10px;
    box-shadow: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--header-text, #0f172a);
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.ail-hdr-lang .lppt-lang-btn:hover {
    background: rgba(109, 94, 252, .08);
    border-color: var(--border-color, #e2e8f0);
    box-shadow: none;
    /* Cancel the plugin's floating-pill lift. */
    transform: none;
}

.ail-hdr-lang .lppt-lang-btn:focus-visible {
    outline: 2px solid var(--primary-color, #6d5efc);
    outline-offset: 2px;
}

.ail-hdr-lang .lppt-lang-btn .lppt-flag {
    font-size: 20px;
    line-height: 1;
}

.ail-hdr-lang .lppt-lang-btn .lppt-lang-name {
    display: none;
}

/* The plugin ships a ▲ caret because its dropdown opened upward from a
   bottom-left float. In the header the panel opens downward, so the resting
   state is flipped to point down and returns to ▲ while open. */
.ail-hdr-lang .lppt-lang-btn .lppt-arrow {
    font-size: 8px;
    opacity: .6;
    transform: rotate(180deg);
    transition: transform .25s ease;
}

.ail-hdr-lang .lppt-lang-switcher.open .lppt-lang-btn .lppt-arrow {
    transform: rotate(0deg);
}

/* ---- Dropdown: opens downward, right-aligned, always inside the viewport ---- */
.ail-hdr-lang .lppt-lang-dropdown {
    top: calc(100% + 10px);
    bottom: auto;
    left: auto;
    right: 0;
    min-width: 210px;
    max-width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--card-bg, #ffffff);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
    padding: 6px;
    /* Replaces the plugin's upward lppt-slideUp animation. */
    animation: ail-lang-drop .18s ease;
    z-index: 21;
}

@keyframes ail-lang-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Options ---- */
.ail-hdr-lang .lppt-lang-option {
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    white-space: nowrap;
}

.ail-hdr-lang .lppt-lang-option:hover {
    background: rgba(109, 94, 252, .08);
}

.ail-hdr-lang .lppt-lang-option.active {
    background: rgba(109, 94, 252, .12);
    font-weight: 700;
}

.ail-hdr-lang .lppt-lang-option:focus-visible {
    outline: 2px solid var(--primary-color, #6d5efc);
    outline-offset: -2px;
}

.ail-hdr-lang .lppt-lang-option .lppt-flag {
    font-size: 18px;
    line-height: 1;
}

.ail-hdr-lang .lppt-lang-option .lppt-check {
    margin-left: auto;
    color: var(--primary-color, #6d5efc);
}

/* ---- Narrow viewports: keep the panel inside the screen ---- */
@media (max-width: 480px) {
    .ail-hdr-lang .lppt-lang-dropdown {
        min-width: 190px;
        max-width: calc(100vw - 24px);
    }

    .ail-hdr-lang .lppt-lang-btn {
        padding: 5px 6px;
    }
}

/* ---- Dark mode parity with the rest of the header ---- */
body.dark-mode .ail-hdr-lang .lppt-lang-btn {
    color: var(--header-text, #f1f5f9);
}

body.dark-mode .ail-hdr-lang .lppt-lang-btn:hover {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .14);
}

body.dark-mode .ail-hdr-lang .lppt-lang-dropdown {
    background: var(--dark-card-bg, #16213e);
    border-color: rgba(255, 255, 255, .12);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

body.dark-mode .ail-hdr-lang .lppt-lang-option {
    color: var(--dark-text, #f1f5f9);
}

body.dark-mode .ail-hdr-lang .lppt-lang-option:hover,
body.dark-mode .ail-hdr-lang .lppt-lang-option.active {
    background: rgba(255, 255, 255, .10);
}

/* ============================================================
   Safety net — the floating widget must never be visible.
   The plugin's footer render is detached in PHP; this guarantees that any
   switcher instance rendered outside the header wrapper stays hidden.
   ============================================================ */
:not(.ail-hdr-lang) > .lppt-lang-switcher {
    display: none !important;
}
