/* Language Selector Styles */
.language-selector {
    position: relative;
    display: inline-block;
    margin-left: 15px;
}

.language-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    color: #ffffff;
    font-size: 20px;
}

.language-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 9999;
    min-width: 120px;
}

.language-selector.active .language-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.language-option:hover {
    background-color: #f5f5f5;
}

.language-option.active {
    background-color: #6366f1;
    color: #ffffff;
}

.language-flag {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.language-flag.de {
    background: linear-gradient(to bottom, #000 33%, #dd0000 33%, #dd0000 66%, #ffce00 66%);
}

.language-flag.en {
    background: linear-gradient(45deg, #012169 25%, transparent 25%), 
                linear-gradient(-45deg, #012169 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #012169 75%), 
                linear-gradient(-45deg, transparent 75%, #012169 75%);
    background-size: 4px 4px;
    background-position: 0 0, 0 2px, 2px -2px, -2px 0px;
    position: relative;
}

.language-flag.en::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(to bottom, #ce1124 0%, #ce1124 20%, transparent 20%, transparent 40%, #ce1124 40%, #ce1124 60%, transparent 60%, transparent 80%, #ce1124 80%),
        linear-gradient(to right, #ce1124 0%, #ce1124 30%, transparent 30%, transparent 70%, #ce1124 70%);
    background-size: 100% 100%, 100% 100%;
}

/* App header specific styling */
.app-header .language-selector {
    margin-left: 0px;
}

.app-header .language-toggle {
    color: #333;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-header .language-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Nav language container */
.nav-language {
    display: flex;
    align-items: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .nav-language .language-selector {
        margin-left: 10px;
        position: static; /* Allow dropdown to escape header container */
    }
    
    .language-toggle {
        padding: 6px;
        font-size: 18px;
    }
    
    .language-dropdown {
        right: -10px;
        position: absolute; /* Keep absolute positioning */
        z-index: 10000; /* Ensure it's above everything */
        max-height: calc(100vh - 80px); /* Prevent extending beyond viewport */
        overflow-y: auto; /* Allow scrolling within dropdown if needed */
    }
    
    /* Override transform for mobile active state */
    .language-selector.active .language-dropdown {
        transform: translateY(0) !important;
    }
    
    .nav-language {
        order: -1; /* Moves language selector before mobile menu button */
        margin-right: 10px;
        position: relative; /* Establish positioning context */
    }
    
    /* Ensure header doesn't clip the dropdown */
    .app-header {
        overflow: visible !important;
    }
    
    .main-nav {
        overflow: visible !important;
    }
}