/* Complete Navigation Styles - Single Source of Truth */
.topnav {
    background-color: #333;
    overflow: visible;
    border-bottom: #77aaff 3px solid;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-family: sans-serif;
}

.topnav a {
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 19px;
    display: block;
}

.topnav a:hover {
    background-color: #39ff14;
    color: black;
}

.topnav a.active {
    background-color: #000000;
    color: white;
}

/* Language toggle styles */
.language-toggle {
    margin-left: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.lang-btn {
    background: #555;
    color: #f2f2f2;
    border: 1px solid #77aaff;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background-color: #39ff14;
    color: black;
}

.lang-btn.active {
    background-color: #39ff14;
    color: black;
    font-weight: bold;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background-color: inherit;
    color: #f2f2f2;
    padding: 14px 16px;
    font-size: 19px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown span.dropbtn {
    cursor: pointer;
}

.dropbtn:hover {
    background-color: #39ff14;
    color: black;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown content - CRITICAL CSS */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #333;
    min-width: 250px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 9999;
    border: 1px solid #77aaff;
    border-top: none;
    top: 100%;
    left: 0;
}

.dropdown-content a {
    color: #f2f2f2;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 16px;
    border-bottom: 1px solid #555;
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: #39ff14;
    color: black;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Right-align the last dropdown (Contact) to prevent cutoff */
.dropdown:last-child .dropdown-content {
    right: 0;
    left: auto;
    min-width: 250px;
}

/* Language toggle dropdown fix */
.nav-links .dropdown:nth-last-child(2) .dropdown-content {
    right: 0;
    left: auto;
    min-width: 250px;
}

/* Navigation layout */
.nav-links {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 0;
    flex-wrap: wrap;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .dropdown:hover .dropdown-content {
        display: none; /* Disable hover on mobile */
    }
    
    .dropdown.active .dropdown-content {
        display: block; /* Show when clicked/active */
    }
    
    .dropdown-content {
        display: none; /* Hidden by default on mobile */
    }

    .topnav {
        flex-direction: column;
        align-items: stretch;
        padding: 0.25rem 0.5rem !important;
    }
    
    .topnav img {
        height: 2rem !important;
        margin: 0.5rem auto !important;
    }
    
    .nav-links {
        margin-left: 0 !important;
        flex-direction: column;
        width: 100%;
    }
    
    .dropdown {
        width: 100%;
    }
    
    .dropbtn {
        width: 100%;
        justify-content: center;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    .topnav a {
        font-size: 0.9rem !important;
        padding: 0.5rem 0.75rem !important;
        text-align: center;
    }
    
    .dropdown-content {
        position: static;
        display: none;
        box-shadow: none;
        border: none;
        background-color: #444;
        min-width: 100%;
    }
    
    .dropdown:hover .dropdown-content {
        display: block;
    }

    .language-toggle {
        margin-left: 0;
        margin-top: 10px;
        justify-content: center;
    }
}

/* Ensure Contact dropdown stays within viewport on smaller screens */
@media (max-width: 1400px) {
    .dropdown:last-child .dropdown-content,
    .nav-links .dropdown:nth-last-child(2) .dropdown-content {
        right: 0;
        left: auto;
        min-width: 220px;
    }
}

@media (max-width: 1200px) {
    .dropdown:last-child .dropdown-content,
    .nav-links .dropdown:nth-last-child(2) .dropdown-content {
        right: 0;
        left: auto;
        min-width: 200px;
    }
}