/* Language Switcher Styles */
.language-switcher {
    position: relative;
    display: inline-block !important;
    margin-left: 15px;
    z-index: 1100; /* Ensure it's above other elements */
}

/* Hover functionality for the entire dropdown container */
.language-switcher:hover .dropdown-menu {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Keep dropdown open when hovering over the dropdown menu itself */
.language-switcher .dropdown-menu:hover {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Add a pseudo-element to create an invisible bridge between button and dropdown */
.language-switcher::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 5px;
    background: transparent;
    z-index: 999;
}

.language-btn {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    color: white !important;
    padding: 8px 15px !important;
    border-radius: 25px !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    min-width: 120px !important; /* Ensure consistent width */
    max-width: 200px !important; /* Prevent oversized buttons */
    overflow: hidden !important; /* Hide overflow text */
    white-space: nowrap !important; /* Prevent text wrapping */
    text-overflow: ellipsis !important; /* Show ellipsis for overflowed text */
}

.language-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.7);
    color: white;
    text-decoration: none;
}

.language-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    color: white;
}

.language-switcher .dropdown-menu {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 2px; /* Reduced gap to prevent hover issues */
    width: 150px; /* Fixed width to prevent flashing */
    min-width: 150px;
    max-width: 150px; /* Enforce consistent width */
    padding: 5px 0;
    display: none; /* Hidden by default */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease; /* Only animate opacity and transform */
    visibility: hidden;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
}

.language-switcher .dropdown-item {
    padding: 8px 15px;
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.language-switcher .dropdown-item:active {
    background-color: #e9ecef;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .language-switcher {
        margin-left: 10px;
    }
    
    .language-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .language-switcher .dropdown-menu {
        width: 130px; /* Fixed width for mobile */
        min-width: 130px;
        max-width: 130px;
    }
}

/* Dark theme navbar adjustments */
.navbar-dark .language-btn {
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    background: rgba(0, 0, 0, 0.3);
}

.navbar-dark .language-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.7);
}

/* Light theme navbar adjustments */
.navbar-light .language-btn {
    border-color: rgba(0, 0, 0, 0.3);
    color: #333;
    background: rgba(255, 255, 255, 0.9);
}

.navbar-light .language-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.5);
}

/* Default navbar (gray background) adjustments */
.navbar .language-btn {
    border-color: rgba(255, 255, 255, 0.6);
    color: white;
    background: rgba(0, 0, 0, 0.4);
}

.navbar .language-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.8);
}

/* Ensure dropdown works properly */
.language-switcher .dropdown-toggle::after {
    display: none;
}

.language-switcher .dropdown-menu.show {
    display: block;
}

/* Animation for smooth transitions */
.language-switcher .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
}

.language-switcher .dropdown-menu.show {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Keep both hover and click functionality working together */
.language-switcher:hover .dropdown-menu,
.language-switcher .dropdown-menu:hover,
.language-switcher .dropdown-menu.show {
    display: block !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Ensure dropdown items maintain hover state */
.language-switcher .dropdown-item:hover {
    background-color: #f8f9fa;
    color: #1A2F6E;
}
