/* ============================================
   Language Switcher — BabaAdventure
   QA-hardened version
   ============================================ */

/* --- Trigger Button (flag + code + chevron) --- */
.language-switcher {
    position: relative;
    display: inline-block;
}

.lang-globe-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: #003366;
}

.flag-nepal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 10px;
    border-radius: 8px;
    border: 1.5px solid #003366;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
    cursor: pointer;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 51, 102, 0.08);
    text-decoration: none !important;
    outline: none;
    user-select: none;
}

.flag-nepal:hover,
.flag-nepal:focus {
    background: #f0f5ff;
    border-color: #002244;
    box-shadow: 0 4px 12px rgba(0, 51, 102, 0.15);
    transform: translateY(-1px);
    outline: none;
}

.flag-nepal .lang-flag-img {
    width: 32px;
    height: 22px;
    object-fit: contain;
    background: #f8fafc;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    display: block;
    flex-shrink: 0;
    padding: 1px;
}

.flag-nepal .lang-code {
    font-size: 13px;
    font-weight: 700;
    color: #003366;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
    font-family: 'Overpass', sans-serif;
}

.flag-nepal .lang-chevron {
    font-size: 11px;
    color: #003366;
    margin-left: 2px;
    transition: transform 0.22s ease;
    line-height: 1;
    display: inline-block;
    font-weight: bold;
}

/* Chevron rotates when dropdown is open */
.flag-nepal.open .lang-chevron {
    transform: rotate(180deg);
}

/* --- Dropdown Panel --- */
.language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid #dcdfe6;
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.16);
    min-width: 220px;
    padding: 8px;
    z-index: 99999;
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lang-dropdown-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 8px 8px;
    border-bottom: 1px solid #edf2f7;
    font-size: 11px;
    font-weight: 700;
    color: #003366;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    margin-bottom: 2px;
}

.lang-dropdown-header svg {
    flex-shrink: 0;
    stroke: #003366;
}

/* Shown state — smooth slide-down */
.language-dropdown.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0s;
}

/* Keep within viewport on small / right-aligned screens */
@media (max-width: 768px) {
    .flag-nepal {
        padding: 7px 12px 7px 8px;
        gap: 6px;
    }
    .flag-nepal .lang-flag-img {
        width: 30px;
        height: 20px;
    }
    .flag-nepal .lang-code {
        font-size: 12px;
    }
    .language-dropdown {
        left: auto;
        right: 0;
        transform: translateY(-6px);
        min-width: 210px;
    }
    .language-dropdown.show {
        transform: translateY(0);
    }
}

/* --- Each Language Option --- */
.language-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #334155;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}

.language-option:hover {
    background: #f0f5ff;
    color: #003366;
}

.language-option:focus {
    outline: 2px solid #003366;
    outline-offset: -2px;
    background: #f0f5ff;
}

.language-option.active {
    background: #e8f0fe;
    font-weight: 600;
    color: #003366;
}

/* Checkmark for active item */
.language-option.active::after {
    content: '✓';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #003366;
    font-weight: 800;
}

.language-option img {
    width: 32px;
    height: 22px;
    object-fit: contain;
    background: #f8fafc;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    padding: 1px;
}

.language-option .opt-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.language-option .opt-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    color: #1e293b;
}

.language-option .opt-code {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.language-option.active .opt-code {
    color: #003366;
}

/* ============================================
   Page Translation Loading Overlay
   ============================================ */
#lang-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#lang-loading-overlay.show {
    display: flex;
    animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Globe icon pulse */
.lang-loading-globe {
    font-size: 40px;
    animation: globePulse 1.2s ease-in-out infinite;
    line-height: 1;
}

@keyframes globePulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%       { transform: scale(1.12); opacity: 0.7; }
}

/* Spinner ring */
.lang-loading-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #e3e8f0;
    border-top-color: #003366;
    border-right-color: #fab127;
    border-radius: 50%;
    animation: spinTwo 0.8s linear infinite;
}

@keyframes spinTwo {
    to { transform: rotate(360deg); }
}

.lang-loading-text {
    font-size: 15px;
    font-weight: 600;
    color: #003366;
    font-family: 'Overpass', sans-serif;
    letter-spacing: 0.2px;
    text-align: center;
}

.lang-loading-sub {
    font-size: 12px;
    color: #999;
    font-family: 'Overpass', sans-serif;
    margin-top: -8px;
    text-align: center;
}

/* Animated dots after sub-text */
.lang-loading-dots::after {
    content: '';
    display: inline-block;
    animation: dotDot 1.4s steps(4, end) infinite;
    letter-spacing: 2px;
    min-width: 18px;
    text-align: left;
}
@keyframes dotDot {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* Progress bar */
.lang-loading-bar-wrap {
    width: 180px;
    height: 3px;
    background: #e3e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.lang-loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #003366, #fab127);
    border-radius: 3px;
    animation: langBarFill 1.5s ease forwards;
}

@keyframes langBarFill {
    0%   { width: 0%; }
    40%  { width: 55%; }
    70%  { width: 80%; }
    90%  { width: 92%; }
    100% { width: 96%; }
}

/* ============================================
   Suppress ALL Google Translate native UI
   ============================================ */
body {
    top: 0px !important;
    position: static !important;
}

/* Banner iframe that shifts the page */
.goog-te-banner-frame,
.goog-te-banner-frame.skiptranslate,
iframe.goog-te-banner-frame,
div.skiptranslate > iframe {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hidden offscreen widget container */
#google_translate_element {
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

.goog-te-gadget,
.goog-te-gadget-simple {
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
}

.goog-te-gadget span,
.goog-te-gadget a,
.goog-te-gadget img,
.goog-te-gadget-icon,
#goog-gt-tt,
.goog-te-balloon-frame,
.skiptranslate:not(font) {
    display: none !important;
    visibility: hidden !important;
}

/* Remove yellow highlight on translated text */
.goog-text-highlight {
    background: transparent !important;
    box-shadow: none !important;
}