/* =================================================================
   LANGUAGE SWITCHER — Google Translate Custom UI
   Fixed floating widget (bottom-left) with custom language panel.
   Matches CollabPals design system (flat, Inter font, indigo primary).
   ================================================================= */

/* --- Container (Fixed Position) --- */
.lang-switcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 5000;
    font-family: var(--font-family-base, 'Inter', sans-serif);
}

/* --- Floating Trigger Button --- */
.lang-switcher__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px 0 12px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    line-height: 1;
}

.lang-switcher__btn:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.lang-switcher__btn--active {
    background-color: var(--color-primary, #4F46E5);
    border-color: var(--color-primary, #4F46E5);
    color: #ffffff;
}

.lang-switcher__btn--active:hover {
    background-color: var(--color-primary-dark, #4338CA);
    border-color: var(--color-primary-dark, #4338CA);
    color: #ffffff;
}

.lang-switcher__btn i {
    font-size: 1rem;
}

.lang-switcher__current {
    letter-spacing: 0.05em;
    font-size: 0.8rem;
}

/* Translated indicator dot — shows when page is not in English */
.lang-switcher__btn--translated::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.lang-switcher__btn {
    position: relative;
}

/* --- Panel (Opens Upward from Button) --- */
.lang-switcher__panel {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 300px;
    max-height: 70vh;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
                0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.lang-switcher__panel--open {
    opacity: 1;
    transform: translateY(0);
}

/* --- Panel Header --- */
.lang-switcher__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
    background-color: #f8fafc;
}

.lang-switcher__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lang-switcher__title i {
    color: var(--color-primary, #4F46E5);
    font-size: 1rem;
}

.lang-switcher__close-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-switcher__close-btn:hover {
    background-color: #e2e8f0;
    color: #64748b;
}

/* --- Search Input --- */
.lang-switcher__search {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.lang-switcher__search-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.lang-switcher__search-input:focus {
    border-color: var(--color-primary, #4F46E5);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.lang-switcher__search-input::placeholder {
    color: #94a3b8;
}

/* --- Panel Body (Scrollable Language List) --- */
.lang-switcher__body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
}

/* Section dividers between language groups */
.lang-switcher__divider {
    height: 1px;
    background-color: #f1f5f9;
    margin: 4px 16px;
}

/* --- Individual Language Button --- */
.lang-switcher__lang {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.12s ease;
    gap: 8px;
    position: relative;
    font-family: inherit;
}

.lang-switcher__lang:hover {
    background-color: #f8fafc;
}

.lang-switcher__lang--active {
    background-color: #eff6ff;
}

.lang-switcher__lang--active:hover {
    background-color: #dbeafe;
}

.lang-switcher__native {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    min-width: 0;
}

.lang-switcher__lang--active .lang-switcher__native {
    color: var(--color-primary, #4F46E5);
}

.lang-switcher__label {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-left: auto;
    flex-shrink: 0;
}

.lang-switcher__check {
    color: var(--color-primary, #4F46E5);
    font-size: 0.75rem;
    margin-left: 6px;
    flex-shrink: 0;
}

/* --- Panel Footer --- */
.lang-switcher__footer {
    padding: 8px 16px;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.lang-switcher__powered {
    font-size: 0.7rem;
    color: #cbd5e1;
}

/* =================================================================
   LANGUAGE NUDGE TOOLTIP
   Auto-detection nudge for non-English browser users. Shown once,
   positioned above the globe button. Dismissed via X or auto after 10s.
   ================================================================= */

.lang-nudge {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 34px 10px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-size: 0.85rem;
    z-index: 1;
}

.lang-nudge--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Small arrow pointing down toward the globe button */
.lang-nudge::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 16px;
    width: 10px;
    height: 10px;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.lang-nudge__greeting {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.9rem;
}

.lang-nudge__text {
    color: #64748b;
}

.lang-nudge__cta {
    background-color: var(--color-primary, #4F46E5);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
    transition: background-color 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.lang-nudge__cta:hover {
    background-color: var(--color-primary-dark, #4338CA);
}

.lang-nudge__dismiss {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}

.lang-nudge__dismiss:hover {
    color: #64748b;
}

/* =================================================================
   GOOGLE TRANSLATE OVERRIDES
   Hide the default Google banner/bar, body offset, and all visual
   artifacts. The translate engine needs its <select> element
   (.goog-te-combo) inside #google_translate_element to remain
   renderable — everything else gets nuked.
   ================================================================= */

/* Hide ALL Google Translate banner/toolbar elements.
   Google renamed .goog-te-banner-frame to obfuscated class names,
   so we target iframe.skiptranslate which is more stable. */
.goog-te-banner-frame,
iframe.skiptranslate {
    display: none !important;
}

/* Google adds a body > div.skiptranslate wrapper for its toolbar UI.
   This is SEPARATE from #google_translate_element (which holds the
   <select> we need). Safe to display:none — the <select> lives in
   our own #google_translate_element div inside the page, not here. */
body > .skiptranslate {
    display: none !important;
}

/* Reset ALL body positioning Google sets (inline styles).
   Google adds: position:relative, top:40px, and sometimes margin-top.
   The translated-ltr/rtl class is on <html>, not <body>. */
.translated-ltr body,
.translated-rtl body {
    top: 0 !important;
    margin-top: 0 !important;
    position: static !important;
}

/* Google sets html { height: 100% } inline — reset to auto so the
   page scrolls naturally. */
html.translated-ltr,
html.translated-rtl {
    height: auto !important;
}

/* Hide the Google Translate gadget visually but keep it functional.
   Uses off-screen positioning (NOT display:none) so the <select>
   element (.goog-te-combo) remains interactive for programmatic control. */
#google_translate_element {
    position: fixed !important;
    top: -200px !important;
    left: -200px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* Google sometimes adds a spinner — hide it */
.goog-te-spinner-pos {
    display: none !important;
}

/* Catch-all: any Google Translate tooltip, popup, or overlay */
.goog-te-menu-value,
.goog-te-gadget,
.goog-tooltip {
    display: none !important;
}

/* =================================================================
   TRANSLATED TEXT OVERFLOW FIXES
   When Google Translate produces longer text than English, buttons
   and nav items can overflow. These rules ONLY apply when the page
   is translated (html.translated-ltr / html.translated-rtl), so the
   English layout stays untouched.
   ================================================================= */

/* Buttons: allow text to wrap instead of overflowing */
.translated-ltr .btn,
.translated-ltr .button,
.translated-ltr .btn-youtube,
.translated-ltr .header-upgrade-btn,
.translated-ltr .alternative-payments__links a,
.translated-rtl .btn,
.translated-rtl .button,
.translated-rtl .btn-youtube,
.translated-rtl .header-upgrade-btn,
.translated-rtl .alternative-payments__links a {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    height: auto !important;
    min-height: 40px;
}

/* Nav links: allow wrapping and slightly smaller text */
.translated-ltr .main-nav a,
.translated-rtl .main-nav a {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    line-height: 1.3;
}

/* Pricing table: tier names, badges, and savings labels */
.translated-ltr .benefit-card__title,
.translated-ltr .benefit-card__price,
.translated-ltr .billing-toggle__savings,
.translated-ltr .result-chip,
.translated-ltr .benefit-badge--chip,
.translated-ltr .benefit-badge--float,
.translated-ltr .benefit-badge--popular,
.translated-rtl .benefit-card__title,
.translated-rtl .benefit-card__price,
.translated-rtl .billing-toggle__savings,
.translated-rtl .result-chip,
.translated-rtl .benefit-badge--chip,
.translated-rtl .benefit-badge--float,
.translated-rtl .benefit-badge--popular {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    text-overflow: ellipsis;
    overflow: visible !important;
}

/* Wallet pill in header: allow content to flex naturally */
.translated-ltr .wallet-section span,
.translated-rtl .wallet-section span {
    white-space: normal !important;
    overflow: visible !important;
}

/* Tab buttons (ambassador dashboard, etc.) */
.translated-ltr .toolkit-tabs__button,
.translated-rtl .toolkit-tabs__button {
    white-space: normal !important;
    overflow-wrap: break-word !important;
}

/* Mobile nav username */
.translated-ltr .mobile-nav-user-name,
.translated-rtl .mobile-nav-user-name {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
}

/* Tables: allow cell text to wrap when translated */
.translated-ltr .table-responsive .table,
.translated-rtl .table-responsive .table {
    white-space: normal !important;
}

/* =================================================================
   RESPONSIVE
   ================================================================= */

@media (max-width: 991px) {
    /* Default: brand/public pages have no bottom nav — keep it low */
    .lang-switcher {
        bottom: 20px;
        right: 16px;
    }

    /* Creator member area: bottom-nav only (no FAB) — lift above nav */
    body:has(.mobile-bottom-nav) .lang-switcher {
        bottom: 92px;
    }

    /* Creator member area: bottom-nav + FAB both present — lift above FAB */
    body:has(.mobile-bottom-nav):has(.mobile-fab) .lang-switcher {
        bottom: 144px;
    }

    /* Brand member area: brand-mobile-fab present (24px bottom + 56px height + 8px gap) */
    body:has(.brand-mobile-fab) .lang-switcher {
        bottom: 88px;
    }

    /* Hire pages: sticky CTA bar visible — lift above it (52px bar + 12px gap) */
    body:has(.hire-sticky-cta--visible) .lang-switcher {
        bottom: 72px;
    }
}

/* Hide language switcher while mobile nav is open to prevent overlap */
body.mobile-nav-open .lang-switcher {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

@media (max-width: 480px) {
    .lang-switcher {
        bottom: 16px;
        right: 12px;
    }

    /* Creator member area */
    body:has(.mobile-bottom-nav) .lang-switcher {
        bottom: 88px;
    }

    /* Brand member area: fab is 52px tall at 20px bottom → top at 72px; add 12px gap */
    body:has(.brand-mobile-fab) .lang-switcher {
        bottom: 84px;
    }

    /* Hire pages: sticky CTA bar */
    body:has(.hire-sticky-cta--visible) .lang-switcher {
        bottom: 68px;
    }

    .lang-switcher__btn {
        height: 36px;
        padding: 0 10px 0 10px;
        font-size: 0.8rem;
    }

    .lang-switcher__panel {
        width: 260px;
        max-height: 60vh;
    }

    .lang-nudge {
        white-space: normal;
        max-width: calc(100vw - 32px);
        right: 0;
        font-size: 0.8rem;
        padding: 8px 30px 8px 10px;
    }
}

/* Tiny phones */
@media (max-width: 360px) {
    .lang-switcher {
        bottom: 84px;
        right: 8px;
    }

    .lang-switcher__panel {
        width: 240px;
    }
}
