/* header.css - Styles for the AI Exam Boost Header */

:root {
    --primary-color: #007bff; /* Blue */
    --primary-hover-color: #0056b3;
    --secondary-color: #6c757d; /* Grey */
    --text-light: #f8f9fa;
    --text-dark: #2c3e50; /* Dark blue-grey */
    --header-bg: #ffffff;
    --header-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --nav-link-color: #343a40;
    --nav-link-hover-color: var(--primary-color);
    --dropdown-bg: #ffffff;
    --dropdown-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.site-header {
    background-color: var(--header-bg);
    padding: 15px 0;
    position: fixed; /* Or 'sticky' if you prefer */
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: var(--header-shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Optional: Scrolled header style */
.site-header.scrolled {
    background-color: rgba(255, 255, 255, 0.98); /* Slightly transparent */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}


.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 1200px; /* Consistent with homepage container */
    margin: 0 auto;
}

/* --- Logo --- */
.logo-container {
    display: flex;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-image {
    height: 40px; /* Adjust as needed */
    width: auto;
    margin-right: 10px;
    border-radius: 4px; /* Optional */
}

.logo-text {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

/* --- Main Navigation --- */
.main-navigation {
    display: flex;
    align-items: center;
}

.student-only,
.teacher-only {
    display: none;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

.nav-list li {
    margin-left: 15px; /* Spacing between nav items */
}

.nav-link {
    color: var(--nav-link-color);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    position: relative;
    border-radius: 20px; /* Keep this for the hover effect */
    transition: color 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

/* The span inside the link now needs to be positioned */
.nav-link span {
    position: relative; /* This becomes the positioning context for the underline */
    z-index: 1;
}

/* --- NEW: Active and Hover Styles --- */

/* Hover effect for all nav links */
.nav-link:hover {
    color: var(--primary-color, #007bff);
    background-color: #f8f9fa; /* A very light grey background on hover */
}

/* Active link style - this is the highlight */
.nav-link.active {
    color: var(--primary-color, #007bff);
    font-weight: 600;
    background-color: transparent; /* Explicitly remove any background */
    box-shadow: none; /* Explicitly remove any shadow */
}

.nav-link.active span::after {
    content: '';
    position: absolute;
    bottom: -5px; /* Adjust vertical position of the underline */
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.nav-link:hover::after,
.nav-link.active span::after {
    width: 100%;
}

/* Dropdown Menu */
.dropdown-li {
    position: relative;
}

.has-dropdown {
    cursor: default; /* Indicate it's not just a link */
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%; /* Position below the parent link */
    left: 0;
    background-color: var(--dropdown-bg, #ffffff);
    list-style: none;
    padding: 10px 0;
    margin: 5px 0 0 0; /* Small gap from parent */
    min-width: 200px;
    border-radius: 6px;
    box-shadow: var(--dropdown-shadow, 0 4px 12px rgba(0,0,0,0.15));
    border: 1px solid #f0f0f0;
    z-index: 1001; /* Above other header content */
}
/* Ensure dropdown items have a transparent background by default */
.dropdown-menu li a.nav-link {
    background-color: transparent !important; /* Use !important as a safeguard if needed */
    color: var(--nav-link-color, #343a40); /* Reset color */
}
/* Style for when a dropdown item is hovered or active */
.dropdown-menu li a.nav-link:hover,
.dropdown-menu li a.nav-link.active {
    background-color: #f8f9fa !important; /* Light grey for hover/active inside dropdown */
    color: var(--primary-color, #007bff);
}

.dropdown-li:hover .dropdown-menu,
.dropdown-li:focus-within .dropdown-menu { /* Show on hover or when an item inside is focused */
    display: block;
}

.dropdown-menu li {
    margin: 0;
}
.dropdown-menu .nav-link {
    padding: 10px 20px;
    display: block;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
}
.dropdown-menu .nav-link::after { /* No underline for dropdown items */
    display: none;
}

/* --- Dropdown Menu (ensure active state is handled) --- */
.dropdown-li {
    /* Style for the top-level dropdown link when a child is active */
    /* You might want a more subtle highlight here */
    color: var(--primary-color, #007bff);
    background-color: transparent; /* No pill for the parent */
    box-shadow: none;
}

.nav-link.has-dropdown.active {
    color: var(--primary-color, #007bff); /* Just change the text color */
    font-weight: 600;
    background-color: transparent; /* Ensure no background pill */
}

/* Remove the dot indicator entirely */
.dropdown-li .nav-link.has-dropdown.active::before {
    display: none;
}

/* Active style for an item INSIDE a dropdown */
.dropdown-menu .nav-link.active {
    background-color: #f0f6ff !important; /* A very light blue highlight */
    color: var(--primary-color, #007bff);
    font-weight: 600;
}



/* --- Authentication Actions --- */
.auth-actions {
    display: flex;
    align-items: center;
}

.auth-links a.btn {
    margin-left: 10px;
    padding: 8px 18px; /* Slightly smaller buttons for header */
    font-size: 0.9em;
}

.btn-primary-header { /* Specific style for header primary button if needed */
    background-color: var(--primary-color);
    color: #fff;
}
.btn-primary-header:hover {
    background-color: var(--primary-hover-color);
    color: #fff;
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}
.btn-outline:hover {
    background-color: var(--primary-color);
    color: #fff;
}


/* User Welcome Section */
.user-welcome {
    display: flex;
    align-items: center;
    position: relative; /* For dropdown positioning */
}

#welcomeUserMessage {
    margin-right: 15px;
    color: var(--nav-link-color);
    font-weight: 500;
    cursor: default;
}

.user-menu-dropdown {
    position: relative;
    cursor: pointer;
    padding-bottom: 10px;
}

.user-avatar-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary-color); /* Optional border */
    object-fit: cover;
}

.user-dropdown { /* Re-use .dropdown-menu styles but position differently */
    display: none;
    position: absolute;
    /* top: calc(100% + 2px); Below avatar with a gap */
    top: 100%;
    right: 0; /* Align to the right */
    background-color: var(--dropdown-bg);
    list-style: none;
    padding: 10px 0;
    margin: 0;
    min-width: 180px;
    border-radius: 6px;
    box-shadow: var(--dropdown-shadow);
    z-index: 1001;
}

.user-menu-dropdown:hover .user-dropdown,
.user-menu-dropdown:focus-within .user-dropdown {
    display: block;
}
.user-dropdown .nav-link {
    padding: 10px 20px;
    display: block;
}


/* --- Mobile Navigation --- */
.menu-toggle {
    display: none; /* Hidden by default, shown in media query */
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 28px; /* Larger hamburger */
    cursor: pointer;
    padding: 5px;
}

@media (max-width: 991px) { /* Breakpoint for mobile nav */
    /* --- Header Actions (Right side: Auth + Hamburger) --- */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 15px; /* Space between auth actions and hamburger if both are visible */
    }
    .menu-toggle {
        display: block;
        order: 1; /* Place hamburger before auth actions if needed */
    }

    .auth-actions {
        order: 2; /* Place auth actions after hamburger */
        margin-left: auto; /* Push auth actions to the right if logo is on left */
    }

    .nav-list {
        display: none; /* Hidden by default on mobile */
        flex-direction: column;
        position: absolute;
        top: 100%; /* Position below the header */
        left: 0;
        width: 100%;
        background-color: var(--header-bg);
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
        padding: 10px 0;
        border-top: 1px solid #eee;
    }
    .nav-list.active { /* Class added by JS to show menu */
        display: flex;
    }
    .nav-list li {
        margin: 0;
        width: 100%;
        text-align: center; /* Center mobile nav items */
    }
    
    /* FIX: Changed selector from .nav-list to .nav-list .nav-link */
    /* These styles apply to each LINK in the mobile menu, not the container */
    .nav-list .nav-link {
        padding: 15px 20px;
        display: block;
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 0;
        color: var(--nav-link-color, #343a40); /* Ensure default text color */
        background-color: transparent; /* Ensure default background */
    }

    .nav-list .nav-link.active {
        background-color: #e6f2ff; /* A very light, subtle blue background */
        color: var(--primary-color, #007bff); /* Blue text color */
        font-weight: 600; /* Make it semi-bold */
        box-shadow: none; /* Ensure no shadow */
    }
    
    /* .nav-link.active:not(.has-dropdown) {
        color: var(--primary-color, #007bff);
        font-weight: 600;
    } */
    .nav-link.active:not(.has-dropdown)::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 16px;
        right: 16px;
        height: 3px;
        background-color: var(--primary-color);
        border-radius: 2px;
    }
    .nav-list li:last-child .nav-link {
        border-bottom: none;
    }
    .nav-link::after { /* No underline for mobile nav items */
        display: none;
    }

    /* Mobile Dropdown Adjustments */
    .dropdown-li:hover .dropdown-menu,
    .dropdown-li:focus-within .dropdown-menu {
        display: none; /* Disable hover for main dropdown on mobile, rely on click/tap */
    }
    .dropdown-li.open .dropdown-menu { /* Class to toggle with JS for mobile dropdown */
        display: block;
        position: static; /* Stack within the mobile nav */
        box-shadow: none;
        border-top: 1px solid #eee;
        background-color: #f7f7f7; /* Slightly different bg for mobile sub-menu */
    }
    .dropdown-menu .nav-link {
        padding-left: 30px; /* Indent mobile sub-menu items */
    }
    .dropdown-li .nav-link.has-dropdown.active {
        background-color: transparent;
        color: var(--primary-color, #007bff);
    }
    .dropdown-li .nav-link.has-dropdown.active::before {
        display: none; /* Hide the dot indicator on mobile */
    }
}