/* ==========================================================
   EARN00 — Language Translator Button & Menu
   Theme-adaptive (works on dark index + light login/signup)
   ========================================================== */

/* Wrapper that hosts the globe button + dropdown */
.tr-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 1100;
}

/* The globe trigger button (used in nav, header, topbar) */
.tr-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    color: #3B82F6;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform .25s cubic-bezier(.4,2,.3,1), background .25s, box-shadow .25s, border-color .25s;
    font-size: 1.05rem;
    position: relative;
}
.tr-btn:hover {
    transform: scale(1.08);
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 6px 22px rgba(59, 130, 246, 0.25);
}
.tr-btn:active { transform: scale(0.95); }
.tr-btn.open {
    background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
    color: #FFFFFF;
    border-color: transparent;
    box-shadow: 0 6px 22px rgba(59, 130, 246, 0.4);
}
.tr-btn .pulse-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: trPulse 2s infinite;
}
@keyframes trPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .5; transform: scale(.85); }
}

/* The dropdown */
.tr-menu {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    min-width: 240px;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 18px;
    background: rgba(15, 18, 26, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(59, 130, 246, 0.18);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    transition: opacity .2s ease, transform .25s cubic-bezier(.4,2,.3,1), visibility 0s linear .25s;
    z-index: 1100;
}
.tr-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity .2s ease, transform .25s cubic-bezier(.4,2,.3,1), visibility 0s;
}

/* Light theme variant — for login.php / signup.php */
.tr-menu.light {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.tr-menu.light .tr-item {
    color: #0f172a;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.tr-menu.light .tr-item:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #0f172a;
}
.tr-menu.light .tr-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(29, 78, 216, 0.15));
    color: #1D4ED8;
}
.tr-menu.light .tr-item .native {
    color: #64748b;
}

/* Menu header (sticky) */
.tr-menu-head {
    padding: 10px 12px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #3B82F6;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.12);
    margin-bottom: 6px;
    position: sticky;
    top: 0;
    background: inherit;
    backdrop-filter: blur(12px);
}
.tr-menu.light .tr-menu-head {
    color: #1D4ED8;
    border-bottom: 1px solid rgba(59, 130, 246, 0.25);
}
.tr-menu-head i { font-size: 0.95rem; }

/* Language items */
.tr-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #e5e7eb;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s, transform .15s;
    user-select: none;
}
.tr-item:hover {
    background: rgba(59, 130, 246, 0.08);
    color: #fff;
    transform: translateX(2px);
}
.tr-item:active { transform: scale(0.98); }
.tr-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(29, 78, 216, 0.15));
    color: #3B82F6;
}
.tr-item .label-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.tr-item .label-block .en {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.1;
}
.tr-item .label-block .native {
    font-size: 0.78rem;
    color: #9CA3AF;
    font-weight: 500;
    line-height: 1.1;
}
.tr-item .check {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: transparent;
    color: #3B82F6;
    font-size: 0.7rem;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity .2s, transform .25s cubic-bezier(.4,2,.3,1);
}
.tr-item.active .check {
    opacity: 1;
    transform: scale(1);
    background: #3B82F6;
    color: #ffffff;
}
.tr-menu.light .tr-item.active .check {
    background: linear-gradient(135deg, #3B82F6, #1D4ED8);
    color: #fff;
}

/* Scrollbar (menu) */
.tr-menu::-webkit-scrollbar { width: 6px; }
.tr-menu::-webkit-scrollbar-track { background: transparent; }
.tr-menu::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.2); border-radius: 100px; }
.tr-menu.light::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.3); }

/* Loading spinner inside the menu */
.tr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    color: #9CA3AF;
    font-size: 0.8rem;
    font-weight: 600;
}
.tr-loading .spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: trSpin 0.8s linear infinite;
}
@keyframes trSpin { to { transform: rotate(360deg); } }

/* ==========================================================
   Fixed top header bar for login / signup pages
   (light theme, sits above the auth layout)
   ========================================================== */
.tr-topbar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 32px);
    max-width: 640px;
    padding: 8px 12px 8px 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 100px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
.tr-topbar .tr-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #0f172a;
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 0.95rem;
}
.tr-topbar .tr-topbar-brand .brand-box {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.tr-topbar .tr-topbar-back {
    text-decoration: none;
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
    transition: color .2s;
}
.tr-topbar .tr-topbar-back:hover { color: #1D4ED8; }

/* When the page already has a top bar, give body room */
body.has-tr-topbar { padding-top: 80px; }
@media (max-width: 480px) {
    .tr-topbar { padding: 6px 8px 6px 14px; }
    .tr-topbar .tr-topbar-brand { font-size: 0.85rem; letter-spacing: 1px; }
    .tr-menu { min-width: 220px; right: -8px; }
}

/* ==========================================================
   Hide Google Translate default UI artifacts
   (banner, tooltip, embedded widget)
   ========================================================== */
body { top: 0 !important; }
.skiptranslate iframe.skiptranslate,
.goog-te-banner-frame.skiptranslate,
#goog-gt-tt,
.goog-tooltip,
.goog-tooltip:hover,
.goog-text-highlight {
    display: none !important;
}
.goog-te-gadget {
    font-size: 0 !important;
    line-height: 0 !important;
}
.goog-te-gadget .goog-te-combo {
    margin: 0 !important;
}
#google_translate_element { display: none !important; }

/* When Google Translate is in RTL mode (Urdu/Arabic) fix the body direction issues */
html[lang="ur"] body,
html[lang="ar"] body {
    direction: rtl;
}
html[lang="ur"] .tr-topbar,
html[lang="ar"] .tr-topbar {
    direction: ltr; /* keep topbar layout consistent */
}
