/**
 * Nafra Overseas - Luxury Worldwide Language Selector Stylesheet
 * Integrates cleanly with navbar aesthetic & sanitizes Google Translate UI
 */

/* ==========================================================================
   0. Instant Translation Anti-Flicker Cloak & RTL Layout Engine
   ========================================================================== */
html.translating-cloak body {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.22s ease-in-out !important;
}

html.translated-ready body {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* RTL Layout Direction Support (Hebrew, Arabic, Urdu, Farsi) */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .navbar-unified-inner {
    flex-direction: row;
}

html[dir="rtl"] .navbar-nav-list {
    flex-direction: row-reverse;
}

html[dir="rtl"] .navbar-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .featured-header-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .featured-carousel-nav {
    flex-direction: row-reverse;
}

html[dir="rtl"] .primary-card-top {
    flex-direction: row-reverse;
}

html[dir="rtl"] .primary-card-meta {
    flex-direction: row-reverse;
}

html[dir="rtl"] .footer-grid {
    direction: rtl;
}

html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-chevron-right {
    transform: scaleX(-1);
}

html[dir="rtl"] .fa-chevron-left {
    transform: scaleX(-1);
}

/* ==========================================================================
   1. Google Translate UI Sanitization (Zero-Bloat, No Displaced Navbar)
   ========================================================================== */
body {
    top: 0px !important;
    position: static !important;
}

.goog-te-banner-frame,
.VIpgJd-ZVi9od-ORHb-OEVmcd,
iframe[id=":1.container"],
iframe.VIpgJd-ZVi9od-ORHb-OEVmcd {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#goog-gt-tt,
.goog-te-balloon-frame {
    display: none !important;
    visibility: hidden !important;
}

.goog-text-highlight,
font.goog-text-highlight,
font[style*="background"] {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

font {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

#google_translate_element,
.google-translate-hidden {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   2. Navbar Language Selector Trigger Button
   ========================================================================== */
.navbar-lang-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.btn-navbar-lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    gap: 0.35rem;
    padding: 0 0.8rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1E293B;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #D1D5DB;
    cursor: url('../images/cursor/cursor-leaf-pointer.png') 2 2, pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.btn-navbar-lang:hover,
.btn-navbar-lang:focus-visible,
.btn-navbar-lang.active {
    background: #0F172A;
    border-color: #0F172A;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-navbar-lang:hover .nav-lang-globe,
.btn-navbar-lang.active .nav-lang-globe {
    color: #FFFFFF;
}

.nav-lang-globe {
    font-size: 0.88rem;
    color: #475569;
    transition: transform 0.3s ease;
}

.btn-navbar-lang:hover .nav-lang-globe {
    transform: rotate(20deg) scale(1.1);
}

.nav-lang-code {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-lang-arrow {
    font-size: 0.65rem;
    opacity: 0.7;
    transition: transform 0.25s ease;
}

.btn-navbar-lang.active .nav-lang-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   3. Floating Luxury Dropdown Panel (Apple iOS Clean White & Frosted Glass)
   ========================================================================== */
.lang-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-width: 94vw;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #E2E8F0;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12), 0 2px 10px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    padding: 16px;
    z-index: 10005;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.98);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.25s;
    pointer-events: none;
}

.lang-dropdown-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Panel Header */
.lang-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid #E2E8F0;
    margin-bottom: 12px;
}

.lang-panel-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-panel-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #0F172A;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lang-panel-title i {
    color: #059669;
}

.lang-panel-badge {
    background: #F1F5F9;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid #E2E8F0;
}

.lang-reset-btn {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: url('../images/cursor/cursor-leaf-pointer.png') 2 2, pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.lang-reset-btn:hover {
    color: #0F172A;
    border-color: #CBD5E1;
    background: #E2E8F0;
}

/* Search Bar */
.lang-search-wrap {
    position: relative;
    margin-bottom: 14px;
}

.lang-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    font-size: 0.85rem;
    pointer-events: none;
}

.lang-search-input {
    width: 100%;
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    border-radius: 10px;
    padding: 9px 34px 9px 34px;
    font-size: 0.84rem;
    color: #0F172A;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
}

.lang-search-input:focus {
    border-color: #0F172A;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
    background: #FFFFFF;
}

.lang-search-input::placeholder {
    color: #94A3B8;
    font-size: 0.8rem;
}

.lang-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: url('../images/cursor/cursor-leaf-pointer.png') 2 2, pointer;
    padding: 4px;
    font-size: 0.8rem;
}

.lang-search-clear:hover {
    color: #0F172A;
}

/* Quick / Popular Trade Languages Grid */
.lang-quick-section {
    margin-bottom: 14px;
}

.lang-section-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748B;
    margin-bottom: 8px;
}

.lang-quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.lang-quick-pill {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 6px 4px;
    cursor: url('../images/cursor/cursor-leaf-pointer.png') 2 2, pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.lang-quick-pill:hover {
    background: #F1F5F9;
    border-color: #CBD5E1;
    transform: translateY(-1px);
}

.lang-quick-pill.active {
    background: #0F172A;
    border-color: #0F172A;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pill-code {
    font-size: 0.7rem;
    font-weight: 800;
    color: #0F172A;
}

.lang-quick-pill.active .pill-code {
    color: #FFFFFF;
}

.pill-name {
    font-size: 0.72rem;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.lang-quick-pill.active .pill-name {
    color: #E2E8F0;
}

/* All Languages List (Scrollable) */
.lang-all-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.lang-active-indicator {
    font-size: 0.7rem;
    color: #059669;
    font-weight: 700;
}

.lang-all-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.lang-all-list {
    flex: 1 1 auto;
    max-height: calc(100vh - 360px);
    min-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Custom Scrollbar */
.lang-all-list::-webkit-scrollbar {
    width: 5px;
}

.lang-all-list::-webkit-scrollbar-track {
    background: #F8FAFC;
    border-radius: 4px;
}

.lang-all-list::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

.lang-all-list::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Language Row Item */
.lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #334155;
    cursor: url('../images/cursor/cursor-leaf-pointer.png') 2 2, pointer;
    text-align: left;
    width: 100%;
    transition: all 0.15s ease;
    box-sizing: border-box;
}

.lang-item:hover {
    background: #F1F5F9;
    border-color: #E2E8F0;
    padding-left: 14px;
    color: #0F172A;
}

.lang-item.active {
    background: #ECFDF5;
    border-color: #A7F3D0;
}

.lang-item.active .lang-check {
    opacity: 1;
    color: #059669;
}

.lang-item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 20px;
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #0F172A;
    flex-shrink: 0;
}

.lang-item-names {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.lang-native-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: #0F172A;
    line-height: 1.2;
}

.lang-english-name {
    font-size: 0.72rem;
    color: #64748B;
    line-height: 1.2;
}

.lang-check {
    opacity: 0;
    font-size: 0.8rem;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.lang-no-results {
    padding: 24px 12px;
    text-align: center;
    color: #94A3B8;
    font-size: 0.85rem;
}

/* ==========================================================================
   4. Mobile & Laptop Responsive Rules
   ========================================================================== */
@media (max-width: 991px) {
    .btn-navbar-lang {
        height: 35px;
        padding: 0 0.72rem;
        font-size: 0.76rem;
        box-sizing: border-box;
    }
    
    .lang-dropdown-panel {
        right: -10px;
        width: 340px;
        max-width: 90vw;
    }
    
    .lang-quick-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 576px) {
    .btn-navbar-lang {
        height: 35px;
        padding: 0 0.65rem;
        font-size: 0.74rem;
        gap: 0.25rem;
        box-sizing: border-box;
    }
    
    .nav-lang-arrow {
        display: none;
    }
    
    .lang-dropdown-panel {
        position: fixed;
        top: 68px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 85px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .lang-all-list {
        max-height: calc(100vh - 350px);
    }
}
