/* Update flag container for brand consistency */
.flag-container {
    width: 24px;
    height: 24px;
    border-radius: 0px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* Update chevron icon for brand consistency */
.chevron-icon {
    display: flex;
    align-items: center;
    color: #041C2F;
    transition: all 0.3s ease;
    margin-left: auto;
}

/* Modern Language Switcher Global Styles */

/* Ensure proper z-index layering */
.modern-language-switcher {
    z-index: 9999;
}

.modern-language-switcher .lang-dropdown {
    z-index: 10000;
}

/* Glass morphism effect for better visual appeal */
.lang-trigger {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.125);
    box-shadow:
        0 8px 32px rgba(31, 38, 135, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Improved dropdown positioning and styling */
.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 0px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.08),
        0 4px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    min-width: 240px;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.modern-language-switcher.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Better option styling */
.lang-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    border-radius: 0px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    gap: 12px;
    position: relative;
    margin: 4px 8px;
}

.lang-option:hover {
    background: #f8fafc;
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.lang-option.active {
    background: linear-gradient(135deg, #FEC201 0%, #F0B90B 100%);
    color: #041C2F;
    transform: translateX(0);
    box-shadow: 0 8px 20px rgba(254, 194, 1, 0.3);
}

.lang-option.active .lang-name,
.lang-option.active .lang-native {
    color: #041C2F;
    font-weight: 600;
}

/* Additional styling for current active language */
.lang-option.current-active {
    background: linear-gradient(135deg, #FEC201 0%, #F0B90B 100%);
    color: #041C2F;
    box-shadow: 0 8px 20px rgba(254, 194, 1, 0.3);
}

.lang-option.current-active .lang-name,
.lang-option.current-active .lang-native {
    color: #041C2F;
    font-weight: 700;
}

/* Improved flag container with better depth */
.flag-container,
.option-flag,
.mobile-flag-container {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Better hover effects */
.lang-option:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%);
    transform: translateX(4px);
    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Mobile grid improvements */
.modern-mobile-language-grid {
    background: linear-gradient(135deg,
            rgba(102, 126, 234, 0.9) 0%,
            rgba(118, 75, 162, 0.9) 50%,
            rgba(64, 93, 230, 0.9) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 8px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Better active state for mobile */
.mobile-lang-option.active {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.08),
        inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

/* Smooth animations for all elements */
.modern-language-switcher *,
.modern-mobile-language-grid * {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Loading state improvements */
.modern-language-switcher.loading .lang-trigger {
    animation: languageSwitcherPulse 1.5s ease-in-out infinite;
}

@keyframes languageSwitcherPulse {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

/* Better scrollbar for language options */
.lang-options::-webkit-scrollbar {
    width: 8px;
}

.lang-options::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
    border-radius: 4px;
}

.lang-options::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-options::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

/* Enhanced focus states */
.lang-trigger:focus-visible,
.lang-option:focus-visible,
.mobile-lang-option:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
    box-shadow:
        0 0 0 3px rgba(59, 130, 246, 0.2),
        0 8px 24px rgba(59, 130, 246, 0.15);
}

/* Improved text rendering */
.current-lang-text,
.lang-name,
.lang-native,
.mobile-lang-name {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Better flag image rendering */
.flag-icon,
.mobile-flag {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .modern-language-switcher {
        transform: scale(0.95);
        transform-origin: right center;
    }

    .lang-trigger {
        padding: 8px 16px;
        min-width: 120px;
        font-size: 13px;
        height: 34px;
    }

    .flag-container {
        width: 20px;
        height: 20px;
    }

    .modern-mobile-language-grid {
        margin: 4px;
        border-radius: 16px;
    }
}

@media (max-width: 480px) {
    .modern-language-switcher {
        transform: scale(0.9);
    }

    .lang-trigger {
        padding: 7px 14px;
        min-width: 110px;
        font-size: 12px;
        height: 32px;
    }

    .current-lang-text {
        font-size: 12px;
    }

    .modern-mobile-language-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .mobile-lang-option {
        min-height: 80px;
        padding: 8px 6px;
    }
}

/* Ensure proper alignment with track button at all breakpoints */
@media (min-width: 1200px) {
    .header-right {
        gap: 20px;
    }

    .lang-trigger {
        min-width: 160px;
    }
}

@media (max-width: 1199px) and (min-width: 769px) {
    .header-right {
        gap: 12px;
    }

    .lang-trigger {
        padding: 8px 16px;
        min-width: 130px;
    }
}

@media (max-width: 480px) {
    .modern-language-switcher {
        transform: scale(0.85);
    }

    .modern-mobile-language-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .mobile-lang-option {
        min-height: 80px;
        padding: 8px 6px;
    }
}

/* Print styles */
@media print {

    .modern-language-switcher,
    .modern-mobile-language-grid {
        display: none !important;
    }
}

/* High performance mode for lower-end devices */
@media (prefers-reduced-motion: reduce) {

    .modern-language-switcher,
    .modern-mobile-language-grid {
        transform: none !important;
        animation: none !important;
    }

    .modern-language-switcher *,
    .modern-mobile-language-grid * {
        transition: none !important;
        animation: none !important;
    }
}

/* Better contrast for accessibility */
@media (prefers-contrast: high) {
    .lang-trigger {
        border-width: 2px;
        border-color: #000;
        background: #fff;
    }

    .current-lang-text {
        color: #000;
        text-shadow: none;
    }

    .lang-dropdown {
        border-width: 2px;
        border-color: #000;
        background: #fff;
    }

    .lang-option.active {
        background: #000;
        color: #fff;
    }

    .mobile-lang-option {
        border-width: 2px;
        border-color: #fff;
    }

    .mobile-lang-option.active {
        background: #fff;
        color: #000;
        border-color: #000;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .lang-dropdown {
        background: rgba(31, 41, 55, 0.95);
        border-color: rgba(55, 65, 81, 0.8);
        box-shadow:
            0 40px 80px rgba(0, 0, 0, 0.3),
            0 16px 32px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.05);
    }

    .lang-option:hover {
        background: rgba(55, 65, 81, 0.8);
    }

    .modern-mobile-language-grid {
        background: linear-gradient(135deg,
                rgba(30, 58, 138, 0.9) 0%,
                rgba(88, 28, 135, 0.9) 100%);
    }
}

/* RTL language support */
[dir="rtl"] .modern-language-switcher {
    direction: rtl;
}

[dir="rtl"] .current-lang-display {
    flex-direction: row-reverse;
}

[dir="rtl"] .lang-option {
    flex-direction: row-reverse;
}

[dir="rtl"] .lang-option:hover {
    transform: translateX(-4px);
}

/* Safari specific fixes */
@supports (-webkit-backdrop-filter: none) {
    .lang-trigger {
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }

    .lang-dropdown {
        -webkit-backdrop-filter: blur(40px) saturate(200%);
    }
}

/* Firefox specific optimizations */
@-moz-document url-prefix() {

    .lang-trigger,
    .lang-dropdown {
        background: rgba(255, 255, 255, 0.9);
    }

    .modern-mobile-language-grid {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
}

/* Ensure proper stacking context */
.header,
.main-header {
    position: relative;
    z-index: 100;
}

/* Better integration with existing header styles */
.box-dropdown-cart .modern-language-switcher {
    margin: 0;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* Align language switcher with track button */
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right .box-dropdown-cart {
    display: flex;
    align-items: center;
}

/* Match track button styling for consistency */
.lang-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 20px;
    background: rgba(254, 194, 1, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(254, 194, 1, 0.3);
    border-radius: 0px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 140px;
    gap: 8px;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.05);
    height: 38px;
    font-size: 14px;
    font-weight: 500;
}

/* Track button matching hover effects */
.lang-trigger:hover {
    background: #034460;
    border-color: #034460;
    transform: translateY(-1px);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(3, 68, 96, 0.2);
}

.lang-trigger:hover .current-lang-text {
    color: #ffffff;
    text-shadow: none;
}

.lang-trigger:hover .chevron-icon {
    color: #ffffff;
}

.lang-trigger:hover .flag-container {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.lang-trigger:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Update current language text color for brand consistency */
.current-lang-text {
    font-size: 14px;
    font-weight: 500;
    color: #041C2F;
    white-space: nowrap;
    text-shadow: none;
}

.mobile-language-menu .modern-mobile-language-grid {
    margin: 0;
    max-width: 100%;
}