.navbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    padding: 10px 3%;
    transition: background-color 0.5s, color 0.5s;
    position: sticky;
    top: 0;
    z-index: 1050;
}

.logo {
    width: 75px;
    height: auto;
    cursor: pointer;
}

.nav-menu {
    flex: 1;
    list-style: none;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.nav-menu li {
    display: inline-block;
    margin: 0 5px;
    font-size: 16px;
}

.nav-menu li a {
    color: inherit;
    text-decoration: none;
    padding: 10px 10px;
    display: inline-block;
    transition: color 0.3s ease;
}

.nav-menu li a:hover {
    color: #0d6efd;
}

.dark .nav-menu li a:hover {
    color: #ffb703;
}

.nav-menu li a.active {
    font-weight: bold;
    color: #0d6efd;
}

.dark .nav-menu li a.active {
    color: #ffb703;
}

.dropdown-trigger.trigger-active {
    font-weight: bold;
    color: #0d6efd;
}

.dark .dropdown-trigger.trigger-active {
    color: #ffb703;
}

.toggle-icon {
    width: 40px;
    height: 40px;
    cursor: pointer;
    margin-left: 40px;
    transition: transform 0.3s ease;
}

.toggle-icon:hover {
    transform: scale(1.1);
}

.search-box {
    display: flex;
    align-items: center;
    background: #242424;
    padding: 10px 20px;
    border-radius: 50px;
    transition: background-color 0.3s ease;
}

.search-box input {
    padding: 6px;
    background: transparent;
    border: 0;
    outline: 0;
    color: #fff;
    font-size: 18px;
    max-width: 200px;
}

.search-box input::placeholder {
    color: #fff;
}

.search-box img {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.dark.navbar {
    background: #000;
    color: #fff;
}

.dark .search-box {
    background: #fff;
}

.dark .search-box input {
    color: #222;
}

.dark .search-box input::placeholder {
    color: #222;
}

/* Dropdown Container */
.dropdown {
    position: relative;
}

.dropdown-trigger {
    cursor: pointer;
    padding: 10px 15px;
    display: inline-block;
    user-select: none;
}

.dropdown-trigger:hover {
    color: #0d6efd;
}

.dark .dropdown-trigger:hover {
    color: #ffb703;
}

/* Hide dropdown by default */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    z-index: 1000;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    text-align: left;
    border-radius: 8px;
    margin-top: 10px;
}

/* 
   Fix for dropdown closing on hover:
   Add an invisible bridge between the trigger and the menu
   matches the margin-top: 10px 
*/
.dropdown-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    background: transparent;
}

.dark .dropdown-menu {
    background-color: #1a1a1a;
    box-shadow: 0 8px 16px rgba(255, 255, 255, 0.1);
}

/* Show dropdown on hover (desktop) */
.dropdown:hover .dropdown-menu {
    display: block;
}

/* Dropdown menu items */
.dropdown-menu li {
    padding: 0;
    margin: 0;
}

.dropdown-menu li a {
    display: block;
    padding: 12px 20px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-menu li a:hover {
    background-color: #f0f0f0;
}

.dark .dropdown-menu li a:hover {
    background-color: #333;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    align-items: center;
    gap: 15px;
}

.toggle-icon-mobile {
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.toggle-icon-mobile:hover {
    transform: scale(1.1);
}

.hamburger {
    display: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    transition: all 0.3s ease-in-out;
    background-color: #333;
}

.dark .bar {
    background-color: #fff;
}

/* Hamburger Animation */
.hamburger .bar.open:nth-child(2) {
    opacity: 0;
}

.hamburger .bar.open:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.hamburger .bar.open:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.desktop-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .navbar {
        padding: 15px 5%;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: #fff;
        width: 100%;
        text-align: left;
        transition: left 0.3s ease-in-out;
        box-shadow: 0 10px 27px rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid #e0e0e0;
        height: auto;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        padding-bottom: 0.5rem;
        gap: 0;
        align-items: flex-start;
    }

    .dark .nav-menu {
        background-color: #1a1a1a;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        display: block;
        margin: 0;
        width: 100%;
        border-bottom: 1px solid #eee;
    }

    .dark .nav-menu li {
        border-color: #333;
    }

    .nav-menu li a {
        padding: 20px;
        display: block;
        font-size: 1.1rem;
        width: 100%;
    }

    .mobile-controls {
        display: flex;
    }

    .hamburger {
        display: block;
    }

    .desktop-controls {
        display: none;
    }

    /* Dropdown on mobile */
    .dropdown {
        position: static;
    }

    .dropdown:hover .dropdown-menu {
        display: none;
    }

    .dropdown.active .dropdown-menu {
        display: block;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        background-color: #f9f9f9;
        padding: 0;
        min-width: 100%;
        transform: none;
        margin: 0;
        border-radius: 0;
    }

    .dark .dropdown-menu {
        background-color: #222;
    }

    .dropdown-menu li {
        border-bottom: 1px solid #e0e0e0;
    }

    .dark .dropdown-menu li {
        border-color: #444;
    }

    .dropdown-menu li a {
        padding: 15px 15px 15px 40px;
        font-size: 1rem;
    }

    .dropdown-trigger {
        display: block;
        padding: 20px;
        width: 100%;
        font-size: 1.1rem;
        text-align: left;
    }

    .dropdown-trigger:hover {
        background-color: #f0f0f0;
    }

    .dark .dropdown-trigger:hover {
        background-color: #333;
    }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .navbar {
        padding: 12px 3%;
    }

    .nav-menu li {
        margin: 0 8px;
        font-size: 16px;
    }

    .search-box input {
        max-width: 150px;
    }
}

/* Accessibility Improvements */
.dropdown-trigger:focus,
.toggle-icon:focus,
.toggle-icon-mobile:focus,
.hamburger:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.dark .dropdown-trigger:focus,
.dark .toggle-icon:focus,
.dark .toggle-icon-mobile:focus,
.dark .hamburger:focus {
    outline-color: #ffb703;
}

/* Smooth transitions for all interactive elements */
.nav-menu li a,
.dropdown-trigger,
.toggle-icon,
.toggle-icon-mobile,
.dropdown-menu {
    transition: all 0.3s ease;
}

/* ── Search Dropdown ── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 420px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    animation: searchSlideIn 0.2s ease;
}

@keyframes searchSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dark .search-dropdown {
    background: #1a1a2e;
    border-color: #333;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.search-header {
    padding: 0.6rem 1rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
}

.dark .search-header {
    color: #777;
    border-color: #333;
}

.search-result {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
    text-decoration: none !important;
    color: inherit;
    cursor: pointer;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover,
.search-result.focused {
    background: rgba(13, 110, 253, 0.06);
}

.dark .search-result {
    border-color: #2a2a3e;
}

.dark .search-result:hover,
.dark .search-result.focused {
    background: rgba(255, 183, 3, 0.08);
}

.search-result-cat {
    display: inline-block;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    background: #0d6efd;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.dark .search-result-cat {
    background: #ffb703;
    color: #1a1a2e;
}

.search-result-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 0.1rem;
}

.search-result-desc {
    display: block;
    font-size: 0.78rem;
    color: #666;
    margin-top: 0.2rem;
    line-height: 1.4;
}

.dark .search-result-desc {
    color: #999;
}

.search-mark {
    background: rgba(13, 110, 253, 0.18);
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

.dark .search-mark {
    background: rgba(255, 183, 3, 0.22);
}

.search-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #888;
    font-size: 0.85rem;
}

.search-empty svg {
    margin-bottom: 0.5rem;
    opacity: 0.4;
}

.search-empty p {
    margin: 0;
}

.search-dropdown::-webkit-scrollbar { width: 4px; }
.search-dropdown::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
.dark .search-dropdown::-webkit-scrollbar-thumb { background: #444; }

