/* ============================================================
   Pure Multilang — Language Switcher
   Style: Native <select>-like dropdown
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────────── */
.pml-switcher,
.pml-switcher * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Wrapper ────────────────────────────────────────────────── */
.pml-switcher {
    position: relative;
    display: inline-block;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1;
    z-index: 9999;
}

/* ── Screen-reader only ─────────────────────────────────────── */
.pml-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   DROPDOWN STYLE  (default)
   Looks like a native <select> — familiar, accessible, clean
   ============================================================ */
.pml-style-dropdown .pml-select-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* The visible button that acts as the select trigger */
.pml-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 32px 5px 10px;   /* right padding leaves room for chevron */
    background: #ffffff;
    border: 1px solid #c8cdd6;
    border-radius: 4px;
    cursor: pointer;
    color: #1a1a2e;
    font-size: inherit;
    font-family: inherit;
    white-space: nowrap;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 110px;
    text-align: left;
    /* Subtle inset shadow like a real <select> */
    box-shadow: inset 0 1px 2px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

.pml-select-btn:hover {
    border-color: #7096c8;
}

.pml-select-btn:focus-visible {
    border-color: #3b7dd8;
    box-shadow: 0 0 0 3px rgba(59,125,216,.2);
}

/* Chevron arrow — drawn with pure CSS, no icon font needed */
.pml-select-btn::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #666;
    pointer-events: none;
    transition: transform 0.15s;
}

.pml-select-btn[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}

.pml-flag {
    font-size: 1.15em;
    line-height: 1;
    flex-shrink: 0;
}

.pml-lang-label {
    font-size: 0.875em;
    color: inherit;
}

/* ── Dropdown panel ─────────────────────────────────────────── */
.pml-options {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #7096c8;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    list-style: none;
    padding: 2px 0;
    z-index: 10000;
}

.pml-options.pml-open {
    display: block;
    animation: pmlFadeIn 0.1s ease;
}

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

/* Scrollbar */
.pml-options::-webkit-scrollbar { width: 5px; }
.pml-options::-webkit-scrollbar-thumb { background: #c0c8d8; border-radius: 3px; }

/* ── Each option ────────────────────────────────────────────── */
.pml-option {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    cursor: pointer;
    color: #1a1a2e;
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: background 0.08s;
    border-left: 3px solid transparent;
}

.pml-option:hover,
.pml-option:focus {
    background: #f0f5fc;
    outline: none;
}

/* Selected / active item — like OS-level select highlight */
.pml-option.pml-selected,
.pml-options li.pml-active .pml-option {
    background: #1a56db;
    color: #fff;
    font-weight: 500;
    border-left-color: #1440b0;
}

.pml-option.pml-selected .pml-flag,
.pml-options li.pml-active .pml-flag {
    filter: none; /* keep flag natural on blue bg */
}

/* Separator line between options */
.pml-options li + li {
    border-top: 1px solid #f0f2f5;
}

/* ============================================================
   LIST STYLE  (horizontal pills)
   ============================================================ */
.pml-style-list .pml-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    list-style: none;
    padding: 0;
}

.pml-style-list .pml-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #c8cdd6;
    border-radius: 3px;
    text-decoration: none;
    color: #1a1a2e;
    font-size: 0.82rem;
    background: #fff;
    transition: border-color 0.12s, background 0.12s;
    cursor: pointer;
}

.pml-style-list .pml-option:hover,
.pml-style-list .pml-option:focus {
    border-color: #3b7dd8;
    background: #f0f5fc;
    outline: none;
}

.pml-style-list .pml-active .pml-option,
.pml-style-list .pml-option.pml-selected {
    background: #1a56db;
    border-color: #1440b0;
    color: #fff;
}

/* ============================================================
   MINIMAL  (flags only, no label)
   ============================================================ */
.pml-style-minimal .pml-minimal {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pml-flag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 3px;
    border: 1px solid transparent;
    text-decoration: none;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.65;
    transition: opacity 0.12s, border-color 0.12s, box-shadow 0.12s;
    cursor: pointer;
}

.pml-flag-btn:hover,
.pml-flag-btn:focus {
    opacity: 1;
    border-color: #c8cdd6;
    outline: none;
}

.pml-flag-btn.pml-selected {
    opacity: 1;
    border-color: #1a56db;
    box-shadow: 0 0 0 2px rgba(26,86,219,.2);
}

/* ============================================================
   RTL support
   ============================================================ */
[dir="rtl"] .pml-select-btn {
    padding: 5px 10px 5px 32px;
    text-align: right;
}
[dir="rtl"] .pml-select-btn::after {
    right: auto;
    left: 10px;
}
[dir="rtl"] .pml-options {
    left: auto;
    right: 0;
}

/* ============================================================
   Dark mode
   ============================================================ */
@media (prefers-color-scheme: dark) {
    .pml-select-btn {
        background: #1e2535;
        border-color: #3a4a6a;
        color: #e2e8f0;
        box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
    }
    .pml-select-btn::after { border-top-color: #94a3b8; }
    .pml-select-btn:hover  { border-color: #6690c8; }

    .pml-options {
        background: #1e2535;
        border-color: #6690c8;
        box-shadow: 0 6px 18px rgba(0,0,0,.4);
    }
    .pml-options li + li { border-top-color: #2a3550; }
    .pml-option { color: #e2e8f0; }
    .pml-option:hover, .pml-option:focus { background: #253045; }
    .pml-option.pml-selected,
    .pml-options li.pml-active .pml-option { background: #1d4ed8; border-left-color: #1e40af; }
}

/* ============================================================
   Mobile: bottom sheet on small screens
   ============================================================ */
@media (max-width: 600px) {
    .pml-style-dropdown .pml-options {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 55vh;
        border-radius: 12px 12px 0 0;
        border: none;
        border-top: 1px solid #e0e6f0;
        box-shadow: 0 -4px 24px rgba(0,0,0,.15);
        padding: 8px 0 env(safe-area-inset-bottom, 8px);
    }
    .pml-style-dropdown .pml-options.pml-open {
        animation: pmlSlideUp 0.18s ease;
    }
    @keyframes pmlSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .pml-option { padding: 11px 18px; font-size: 1rem; }
}
