#top-nav {
    max-width: 800px;
    height: var(--top-nav-height);
    top: 0;
    left: var(--side-bar-width);
    right: 0;
    z-index: 1009;
    background-color: white !important;
    margin: 0 !important;
    border-bottom: 1px solid #e5e5e5 !important;
    display: flex;
    align-items: center;
    justify-content: left;
    position: fixed;
    padding-left: var(--content-padding-left);
}

#nav-menu {
    display: flex;
    align-items: center;
    height: 100%;
}

/* --- Dropdown Container --- */
.dropdown {
    position: relative;
    display: inline-block;
    height: 100%;
}

/* --- Main Category Buttons --- */
.dropbtn {
    background-color: transparent;
    color: black;
    padding-left: 0;
    padding-right: 2vw;
    font-size: 16px;
    border: none;
    cursor: pointer;
    height: 100%; /* Fill top nav height */
    font-weight: bold;
    display: flex;
    align-items: center;
    position: relative;
    white-space: nowrap;
}

/* Optional: Add a small arrow gap */
.dropbtn i {
    margin-left: 5px;
    font-size: 16px;
    color: #666;
}

/* Underline Animation for Main Categories (Preserving your original style) */
.dropbtn::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0px; /* Aligned to bottom of nav */
    width: 0;
    height: 4px; /* Thickness of blue line */
    background-color: #007bff;
    transition: width 0.4s ease-in-out;
    z-index: 1011;
}

.dropdown:hover .dropbtn::before {
    width: 80%; /* Expand line on hover */
}

/* --- Dropdown Content (The sub-menu) --- */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1012;
    top: var(--top-nav-height); /* Position right below the header */
    left: 0;
    border-radius: 0 0 4px 4px;
    border-top: 1px solid #eee;
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}

/* Show dropdown on hover */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Links inside the dropdown */
.dropdown-content a {
    color: black;
    padding: 0.25em 1em;
    text-decoration: none;
    display: block;
    font-size: 16px;
    font-weight: normal;
    text-align: left;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: #007bff;
}

/* --- Responsive Layout (Small Screens) --- */
@media (max-width: 768px) {
    #top-nav {
        /* Reset positioning for mobile to ensure full width */
        top: var(--top-nav-height);
        left: 0;
        width: 100%;
        padding: 0;
        justify-content: center;
    }

    /* Hide the Hamburger Icon */
    #hamburger-menu {
        display: none !important;
    }

    /* Force Menu to display Horizontally */
    #nav-menu {
        display: flex !important;
        position: static;
        flex-direction: row;
        width: 100%;
        height: 100%;
        background-color: transparent;
        box-shadow: none;
        justify-content: space-around;
    }

    /* Adjust Dropdown Containers */
    .dropdown {
        width: auto;
        display: flex;
        justify-content: center;
        align-items: center;
        position: static;
    }

    /* Buttons */
    .dropbtn {
        width: 100%;
        padding: 0 5px;
        font-size: 14px;
        border-bottom: none;
        justify-content: center;
        text-align: center;
    }

    .dropbtn i {
        margin-left: 3px;
        font-size: 14px;
    }

    .dropbtn::before {
        display: none;
    }

    /* Dropdown Content */
    /* Disable hover effect on mobile so JS has full control */
    .dropdown:hover .dropdown-content {
        display: none;
    }

    .dropdown-content {
        display: none;
        position: fixed;
        top: calc(var(--top-nav-height) * 2);
        left: 0;
        width: 100%;
        background-color: #f9f9f9;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        border-top: 1px solid #ddd;
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Helper class to show content via JS */
    .dropdown-content.show-mobile {
        display: block !important;
    }

    .dropdown-content a {
        padding: 1em 2em;
        font-size: 14px;
        border-bottom: 1px solid #eee;
    }
}

@media (max-width: 480px) {
    /* Style the Buttons for Mobile (Compact) */
    .dropbtn {
        font-size: 13px;
    }

    .dropbtn i {
        font-size: 13px;
    }

    .dropdown-content a {
        font-size: 13px;
    }
}
