/* Style/navbar.css - MODIFIED FOR PROPER ALIGNMENT */

.main-header {
    background-color: var(--nav-bg);
    color: var(--nav-text);
    padding: 15px 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 998;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box; /* ADDED */
}

.nav-logo a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.nav-logo img {
    height: 40px;
}

/* FIXED: Main navigation centering */
.main-nav {
    flex: 1; /* ADDED: Take available space */
    display: flex;
    justify-content: center; /* ADDED: Center navigation */
    align-items: center;
}

.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 30px; /* CHANGED: Use gap instead of margin for consistent spacing */
}

.main-nav ul li {
    /* REMOVED: margin-left: 20px; */
    position: relative;
    display: flex; /* ADDED */
    align-items: center; /* ADDED */
}

/* REMOVED: .main-nav ul li:first-child margin reset - not needed with gap */

.main-nav ul li a {
    text-decoration: none;
    color: var(--nav-text);
    padding: 8px 12px;
    display: block;
    transition: color 0.3s ease-in-out;
    white-space: nowrap; /* ADDED: Prevent text wrapping */
    height: 40px; /* ADDED: Consistent height */
    display: flex; /* ADDED */
    align-items: center; /* ADDED */
    box-sizing: border-box; /* ADDED */
}

.main-nav ul li a:hover {
    color: var(--nav-hover-text);
    background-color: var(--nav-hover-bg);
    border-radius: 5px;
}

/* FIXED: Dropdown toggle styling */
.dropdown-toggle {
    display: flex !important; /* ADDED */
    align-items: center !important; /* ADDED */
    height: 40px !important; /* ADDED: Same height as other nav items */
    box-sizing: border-box !important; /* ADDED */
}

.dropdown-toggle::after {
    content: '\25BE'; /* Down arrow */
    margin-left: 5px;
    vertical-align: middle;
    transition: transform 0.3s ease; /* ADDED: Smooth rotation */
}

/* ADDED: Rotate arrow on hover */
.dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 100%;
    left: 50%; /* CHANGED: Center dropdown under parent */
    transform: translateX(-50%) translateY(-10px); /* CHANGED: Center horizontally */
    background-color: var(--nav-dropdown-bg);
    color: var(--nav-dropdown-text);
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0.3s;
    z-index: 10;
    min-width: 180px; /* ADDED: Minimum width */
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0); /* CHANGED: Center horizontally when shown */
}

.dropdown-menu li a {
    padding: 10px 15px;
    display: block;
    text-decoration: none;
    color: var(--nav-dropdown-text);
    transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out;
    white-space: nowrap;
    height: auto; /* CHANGED: Allow natural height for dropdown items */
}

.dropdown-menu li a:hover {
    background-color: var(--nav-dropdown-hover-bg);
    color: var(--nav-dropdown-hover-text);
}

/* Theme Toggle Button Container */
.theme-toggle-container {
    display: flex;
    align-items: center;
    flex-shrink: 0; /* ADDED: Prevent shrinking */
}

/* Theme Toggle Button */
#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

#theme-toggle.icon-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
}

#theme-toggle.icon-button img {
    max-width: 100%;
    height: auto;
    display: block;
    /* REMOVED: margin-right: 60px; - this was causing alignment issues */
}

/* REMOVED: Apply margin-right for desktop view - not needed */

/* Mobile Navigation (Hamburger Menu) */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    width: 30px;
    height: 24px;
    justify-content: space-between;
    flex-shrink: 0; /* ADDED */
}

.hamburger .bar {
    height: 3px;
    width: 100%;
    background-color: var(--nav-text);
    transition: 0.3s;
}

/* ADDED: Hamburger animation */
.hamburger.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger.active .bar:nth-child(2) {
    opacity: 0;
}

.hamburger.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Responsive Design */
@media (max-width: 960px) {
    .main-header {
        padding-right: 20px;
        justify-content: space-between; /* ADDED: Ensure proper mobile layout */
    }

    /* FIXED: Mobile navigation layout */
    .main-nav {
        display: none;
        position: absolute;
        top: 100%; /* CHANGED: Use 100% instead of 60px */
        left: 0;
        right: 0; /* ADDED */
        background-color: var(--nav-bg);
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        padding: 10px;
        justify-content: flex-start; /* ADDED */
    }

    .main-nav.open {
        display: flex;
    }

    .main-nav ul {
        flex-direction: column;
        width: 100%;
        gap: 0; /* CHANGED: Reset gap for mobile */
    }

    .main-nav ul li {
        margin: 0;
        width: 100%;
        display: block; /* CHANGED: Block display for mobile */
    }

    .main-nav ul li a {
        padding: 15px 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        height: auto; /* CHANGED: Auto height for mobile */
        display: block; /* CHANGED: Block display for mobile */
    }

    .main-nav ul li a:hover {
        background-color: var(--nav-hover-bg);
        color: var(--nav-hover-text);
        border-radius: 0;
    }

    /* Mobile Dropdown Styles */
    .main-nav .dropdown .dropdown-menu {
        position: static !important;
        display: none !important;
        width: 100% !important;
        box-shadow: none !important;
        transform: none !important; /* CHANGED */
        opacity: 1 !important;
        visibility: visible !important;
        background-color: var(--nav-dropdown-bg) !important;
        border-radius: 0 !important;
        margin-top: 0 !important;
        padding-left: 20px !important;
    }

    .main-nav .dropdown.open .dropdown-menu {
        display: block !important;
    }

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

    .main-nav .dropdown-menu li a {
        padding-left: 40px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .hamburger {
        display: flex;
    }

    /* FIXED: Mobile layout order */
    .theme-toggle-container {
        order: 2;
        margin-left: auto;
        margin-right: 15px;
    }

    .nav-logo {
        order: 1;
    }

    .hamburger {
        order: 3;
        margin-left: 10px;
        margin-right: 0; /* CHANGED */
    }

    .main-nav ul li:last-child a {
        border-bottom: none;
    }

    /* Mobile Hover/Active Feedback */
    .main-nav ul li a:active {
        background-color: var(--nav-hover-bg);
        color: var(--nav-hover-text);
    }

    .main-nav .dropdown-menu li a:active {
        background-color: var(--nav-dropdown-hover-bg);
        color: var(--nav-dropdown-hover-text);
    }
}

/* ADDED: Better visual hierarchy */
@media (min-width: 961px) {
    .main-header {
        padding: 15px 40px; /* ADDED: More padding on desktop */
    }
    
    .main-nav ul {
        gap: 35px; /* ADDED: Slightly more space on desktop */
    }
}

/* ADDED: Smooth transitions for better UX */
.main-nav ul li a,
.dropdown-toggle {
    transition: all 0.3s ease;
}

.main-nav ul li a:hover,
.dropdown-toggle:hover {
    transform: translateY(-1px);
}
