/* TH Simple Translate – Frontend Language Switcher */

.thst-lang-switcher {
    display: inline-block;
    position: relative;
}

.thst-lang-select {
    padding: 6px 30px 6px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: auto;
    min-width: 150px;
}

.thst-lang-select:hover {
    border-color: #999;
}

.thst-lang-select:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

/* List style */
.thst-lang-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.thst-lang-item a {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: all 0.2s;
}

.thst-lang-item a:hover {
    background: #f0f0f0;
    border-color: #999;
}

.thst-lang-item.thst-lang-active a {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* ── Flag (emoji) mode ────────────────────────────────────────────── */

/* Dropdown-style: flag buttons rendered as a flex row of emoji links */
.thst-lang-switcher--flags {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.thst-flag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 26px;
    line-height: 1;
    border: 2px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}

.thst-flag-btn:hover {
    border-color: #ccc;
    background: #f5f5f5;
}

.thst-flag-btn.thst-lang-active {
    border-color: #0073aa;
    background: #e8f3fb;
}

/* List style with flags */
.thst-lang-list--flags {
    gap: 4px;
}

.thst-lang-list--flags .thst-lang-item a {
    font-size: 26px;
    line-height: 1;
    padding: 6px 8px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Flag dropdown (dropdown layout + flags mode) ─────────────────── */

.thst-flag-dropdown {
    position: relative;
    display: inline-block;
}

.thst-flag-dropdown-toggle,
.thst-flag-dropdown .thst-flag-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    font-size: 26px;
    line-height: 1;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 44px;
    color: inherit;
}

.thst-flag-dropdown-toggle:hover,
.thst-flag-dropdown .thst-flag-dropdown-toggle:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

.thst-dropdown-arrow {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.thst-flag-dropdown-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    min-width: 56px;
}

.thst-flag-dropdown.thst-open .thst-flag-dropdown-list {
    display: block;
}

.thst-flag-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    font-size: 26px;
    line-height: 1;
    text-decoration: none;
    color: inherit;
    min-height: 44px;
    transition: background 0.12s;
}

.thst-flag-dropdown-item:hover {
    background: #f5f5f5;
}

.thst-flag-dropdown-item.thst-lang-active {
    border-left: 3px solid #6b8e7f;
    padding-left: 7px; /* compensate for border */
}

/* ── Translation-in-progress overlay (deferred long pages + browser provider)
 *
 * Warning, not alarm: amber #ffc107 by default. Operators override
 * colour and height in Settings; those values arrive as CSS custom
 * properties on :root (see THST_Settings::progress_overlay_inline_css).
 * Fallbacks below match THST_PROGRESS_OVERLAY_* in th-simple-translate.php
 * so the bar still looks right if inline CSS is missing.
 * The JS only sets the element id/class — it does not carry colours.
 * ─────────────────────────────────────────────────────────────────── */

#thst-progress-overlay,
#thst-progress,
#thst-download-hint,
#thst-translated-badge,
.thst-progress-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--thst-progress-overlay-padding-y, 12px) 16px;
    background: var(--thst-progress-overlay-bg, rgba(255, 193, 7, 0.88));
    color: var(--thst-progress-overlay-fg, #3d3424);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    z-index: 99990;
    pointer-events: none;
    box-sizing: border-box;
    font-family: system-ui, sans-serif;
}

/* Failure state — deferred-fill translation could not be produced at all.
 * Fixed danger red (THST_PROGRESS_OVERLAY_ERROR_COLOR, #dc3545), NOT the
 * operator-configurable --thst-progress-overlay-bg/-fg above: a failure
 * must always read as an alert, regardless of the chosen status-bar
 * colour. See THST_Translation_Render::OVERLAY_FAILURE_DISPLAY_MS. */
/* ID + class so this beats the `#thst-progress-overlay` rule above.
 * Two classes alone lose to an ID (specificity 0,2,0 vs 1,0,0), which
 * is why the failure banner used to keep the warning-amber background. */
#thst-progress-overlay.thst-progress-overlay--error,
.thst-progress-overlay.thst-progress-overlay--error {
    background: var(--thst-progress-overlay-error-bg, rgba(220, 53, 69, 0.95));
    color: var(--thst-progress-overlay-error-fg, #ffffff);
}
