/**
 * Multi-level Navigation Styles for ExamHub Theme
 */

/* Header Integration */
.site-header {
    position: sticky;
    top: 0;
    z-index: 9998;
    background: white;
    border-bottom: 1px solid #e1e5e9;
    transition: all 0.3s ease;
}

.site-header.header-scrolled {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.site-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 70px;
}

/* Main Navigation Container */
.main-navigation {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.primary-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

/* Top Level Menu Items */
.primary-menu>li {
    position: relative;
}

.primary-menu>li>a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.primary-menu>li>a:hover,
.primary-menu>li>a:focus {
    background: #f8f9fa;
    color: #007cba;
}

/* Menu items with children */
.primary-menu .menu-item-has-children>a::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 0.5rem;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    transition: transform 0.2s ease;
}

.primary-menu .menu-item-has-children:hover>a::after,
.primary-menu .menu-item-has-children.menu-open>a::after {
    transform: rotate(180deg);
}

/* Dropdown Containers */
.sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e1e5e9;
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

/* First level dropdown - show on hover or when menu-open class is present */
.primary-menu>.menu-item-has-children:hover>.sub-menu,
.primary-menu>.menu-item-has-children.menu-open>.sub-menu,
.primary-menu>.menu-item-has-children>a:focus+.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Second level dropdown - only show on hover of the parent item */
.sub-menu>.menu-item-has-children:hover>.sub-menu,
.sub-menu>.menu-item-has-children>a:focus+.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Third level dropdown - only show when explicitly opened with menu-open class */
.sub-menu .sub-menu .menu-item-has-children.menu-open>.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Hide all nested submenus by default */
.sub-menu .sub-menu {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
}

/* Second Level Menu Items */
.sub-menu>li {
    position: relative;
}

.sub-menu>li>a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0;
}

.sub-menu>li>a:hover,
.sub-menu>li>a:focus {
    background: #f8f9fa;
    color: #007cba;
}

/* Third Level (Sub-sub-menu) */
.sub-menu .menu-item-has-children>a::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 4px solid currentColor;
    transition: transform 0.2s ease;
}

.sub-menu .menu-item-has-children:hover>a::after,
.sub-menu .menu-item-has-children.menu-open>a::after {
    transform: rotate(90deg);
}

/* Third Level Dropdown */
.sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-left: 0.5rem;
}

/* Position third level on the right by default - removed since handled above */

/* Adjust position for items near viewport edge */
@media (max-width: 1200px) {
    .sub-menu .sub-menu {
        left: -100%;
        margin-left: -0.5rem;
    }

    .sub-menu>.menu-item-has-children:hover>.sub-menu,
    .sub-menu>.menu-item-has-children.menu-open>.sub-menu,
    .sub-menu>.menu-item-has-children>a:focus+.sub-menu {
        left: -100%;
        margin-left: -0.5rem;
    }
}

/* Prevent dropdowns from overflowing viewport */
.sub-menu {
    max-width: calc(100vw - 2rem);
}

.mcq-dropdown {
    max-width: calc(100vw - 2rem);
}

.user-dropdown {
    max-width: calc(100vw - 2rem);
}

/* Dynamic positioning based on viewport space */
.sub-menu .menu-item-has-children {
    position: relative;
}

.sub-menu .menu-item-has-children .sub-menu {
    position: absolute;
}

/* Menu Item Separators */
.sub-menu>li:not(:last-child) {
    border-bottom: 1px solid #f1f3f4;
}

/* Menu Item Icons */
.menu-item a i {
    margin-right: 0.5rem;
    width: 16px;
    text-align: center;
}

/* Active/Current Menu Items */
.current-menu-item>a,
.current-menu-parent>a,
.current-menu-ancestor>a {
    color: #007cba;
    background: #f0f8ff;
}

/* User Menu Dropdown */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.user-menu-toggle:hover {
    background: #f8f9fa;
    border-color: #007cba;
}

.user-menu-toggle .dropdown-arrow {
    transition: transform 0.2s ease;
}

.user-menu-toggle[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007cba;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-name {
    font-weight: 500;
    color: #333;
}

.subscription-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.subscription-badge.premium {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 280px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e1e5e9;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
    overflow: hidden;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.user-info strong {
    display: block;
    color: #333;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.user-info span {
    color: #666;
    font-size: 0.8rem;
}

.dropdown-menu {
    padding: 0.5rem 0;
}

.dropdown-divider {
    height: 1px;
    background: #e1e5e9;
    margin: 0.5rem 0;
    border: none;
}

/* MCQ Quick Access Dropdown */
.mcq-quick-access {
    position: relative;
}

.mcq-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.mcq-dropdown-toggle:hover {
    background: #005a87;
}

.mcq-dropdown-toggle .dropdown-arrow {
    transition: transform 0.2s ease;
}

.mcq-dropdown-toggle[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.mcq-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 600px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e1e5e9;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.mcq-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section h4 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #007cba;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: #007cba;
    padding-left: 0.5rem;
}

.dropdown-item.view-all {
    font-weight: 600;
    color: #007cba;
    border-top: 1px solid #e1e5e9;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.dropdown-item .count {
    font-size: 0.8rem;
    color: #666;
    margin-left: auto;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
}

.search-toggle:hover {
    background: #f8f9fa;
    border-color: #007cba;
    color: #007cba;
}

.search-toggle:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Mobile Navigation Adjustments */
@media (max-width: 768px) {
    .main-navigation {
        display: none;
        /* Hidden on mobile, use mobile menu instead */
    }

    .mcq-dropdown {
        grid-template-columns: 1fr;
        min-width: 300px;
        max-width: 90vw;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .user-name {
        display: none;
        /* Hide username on mobile to save space */
    }

    .auth-buttons {
        gap: 0.5rem;
    }

    .auth-buttons .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Adjust dropdown positioning on mobile */
    .user-dropdown {
        right: -1rem;
        min-width: 250px;
    }

    .mcq-dropdown {
        left: -1rem;
        right: -1rem;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .header-container {
        padding: 0 0.75rem;
    }

    .user-dropdown {
        right: -0.75rem;
        min-width: 220px;
    }

    .dropdown-header {
        padding: 0.75rem 1rem;
    }

    .user-info strong {
        font-size: 0.85rem;
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

/* Mobile Menu Styles */
.mobile-navigation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-navigation.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 90vw;
    height: 100%;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-navigation.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.mobile-menu-header h3 {
    margin: 0;
    color: #333;
}

.mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.mobile-menu-close:hover {
    background: #e9ecef;
    color: #333;
}

/* Mobile Menu List */
.mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu li {
    border-bottom: 1px solid #f1f3f4;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
}

.mobile-menu a:hover,
.mobile-menu a:focus {
    background: #f8f9fa;
    color: #007cba;
}

/* Mobile Submenu Toggle */
.mobile-menu .menu-item-has-children>a::after {
    content: "+";
    font-size: 1.2rem;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.mobile-menu .menu-item-has-children.menu-open>a::after {
    content: "−";
    transform: rotate(0deg);
}

/* Mobile Submenu */
.mobile-menu .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #f8f9fa;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-menu .menu-item-has-children.menu-open>.sub-menu {
    max-height: 1000px;
    /* Increased for third level menus */
}

/* Second level menu items */
.mobile-menu .sub-menu a {
    padding-left: 2.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

/* Third level menu items */
.mobile-menu .sub-menu .sub-menu a {
    padding-left: 3.5rem;
    background: #f1f3f4;
}

/* Fourth level menu items (if needed) */
.mobile-menu .sub-menu .sub-menu .sub-menu a {
    padding-left: 4.5rem;
    background: #e9ecef;
}

/* Ensure nested submenus work correctly */
.mobile-menu .sub-menu .menu-item-has-children.menu-open>.sub-menu {
    max-height: 800px;
}

.mobile-menu .sub-menu .sub-menu .menu-item-has-children.menu-open>.sub-menu {
    max-height: 600px;
}

/* Mobile Menu Actions */
.mobile-menu-actions {
    padding: 1.5rem;
    border-top: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.mobile-menu-actions .btn {
    width: 100%;
    margin-bottom: 0.75rem;
    justify-content: center;
}

.mobile-menu-actions .btn:last-child {
    margin-bottom: 0;
}

/* Button styles moved to buttons.css */

/* Accessibility Improvements */
.menu-item a:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Skip focus to submenu items when parent is focused */
.menu-item-has-children>a:focus+.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Keyboard Navigation */
.menu-item-has-children>a[aria-expanded="true"]+.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .sub-menu {
        border: 2px solid #000;
    }

    .menu-item a {
        border: 1px solid transparent;
    }

    .menu-item a:focus {
        border-color: #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {

    .sub-menu,
    .mobile-menu-content,
    .menu-item-has-children>a::after {
        transition: none;
    }
}

/* Print Styles */
@media print {

    .main-navigation,
    .mobile-navigation {
        display: none;
    }
}