/*!
 * Aera Grão - Seletor de idioma com bandeiras (js/i18n/i18n.js)
 *   .lang-flags   linha com as três bandeiras (tela de login, Minha conta)
 *   .lang-picker  botão com a bandeira atual e a lista de idiomas (barra superior e trilho do simulador)
 */
.flag {
    display: block;
    flex: none;
    width: 22px;
    height: 15.7px;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, .28);
    overflow: hidden;
}

/* ------------------------- Linha de bandeiras ------------------------- */
.lang-flags { display: inline-flex; flex: none; align-items: center; gap: 4px; }
.lang-flag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 9px 0 7px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.lang-flag .flag { opacity: .72; filter: saturate(.75); transition: opacity .15s, filter .15s; }
.lang-flag:hover { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.lang-flag:hover .flag, .lang-flag.active .flag { opacity: 1; filter: none; }
.lang-flag.active { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); cursor: default; }
.lang-flag:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Tela de login: no canto direito da marca */
.auth-brand .lang-flags { margin-left: auto; }
@media (max-width: 420px) {
    .auth-brand { flex-wrap: wrap; }
    .auth-brand .lang-flags { margin-left: 0; width: 100%; }
    .lang-flag { flex: 1; justify-content: center; }
}

/* Minha conta: bloco "Idioma" (na seção Aparência) */
.account-subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.account-subsection h3 { color: var(--text); font-size: 14px; font-weight: 650; }
.account-subsection .field-sub { display: block; margin: 4px 0 10px; }
.lang-flags.lang-flags-large { flex-wrap: wrap; gap: 8px; }
.lang-flags-large .lang-flag { height: 40px; padding: 0 14px 0 10px; font-size: 13.5px; font-weight: 600; letter-spacing: 0; }
.lang-flags-large .flag { width: 26px; height: 18.6px; }

/* Minha conta, tema em uso (o texto vem do CSS, em css/shell.css) */
:root[lang="en"] .theme-option:has(input:checked) .theme-option-text b::after { content: " · in use"; }
:root[lang="es"] .theme-option:has(input:checked) .theme-option-text b::after { content: " · en uso"; }

/* ------------------------- Botão com lista ------------------------- */
.lang-picker { position: relative; flex: none; margin-left: auto; }
.lang-picker + .theme-toggle { margin-left: 2px; }
.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-faint);
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.lang-toggle:hover, .lang-toggle[aria-expanded="true"] { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.lang-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.page-actions ~ .lang-picker { margin-left: 0; }

.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 210px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface-2);
    box-shadow: 0 16px 40px var(--shadow);
}
.lang-menu[hidden] { display: none; }
.lang-menu-head { padding: 6px 10px 4px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.lang-option:hover, .lang-option:focus-visible { background: var(--surface-hover); outline: none; }
.lang-option > span { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.lang-option b { font-size: 13.5px; font-weight: 600; }
.lang-option small { color: var(--text-faint); font-size: 11.5px; }
.lang-check { width: 16px; height: 16px; fill: none; stroke: var(--accent-text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.lang-option.active .lang-check { visibility: visible; }

/* Trilho do simulador: botão quadrado, lista abre para a direita */
.lang-picker.in-rail { margin: 4px auto 0; }
.lang-picker.in-rail .lang-toggle { justify-content: center; width: 40px; height: 40px; padding: 0; }
.lang-picker.in-rail .lang-menu { top: auto; right: auto; bottom: 0; left: calc(100% + 8px); }

@media (max-width: 640px) {
    .lang-toggle span { display: none; }
    .lang-toggle { padding: 0 7px; }
}
