/* styles/components/header.css */

.site-header {
    background-color: var(--background-color);
    color: var(--text-color);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    background-color: var(--background-alt); /* Slightly different background when scrolled */
}


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

.logo a {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.main-nav {
    display: flex;
    align-items: center;
}

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

.nav-list li {
    margin-left: 1.5rem;
    position: relative; /* Needed for dropdown positioning */
}

.nav-list li:first-child {
    margin-left: 0;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

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

/* Header Actions (Search, Theme, Language) */
.header-actions {
    display: flex;
    align-items: center;
    margin-left: 2rem; /* Space between nav links and actions */
}

.search-container {
    position: relative;
    margin-right: 1rem;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    padding: 0.4rem 0.8rem;
    padding-right: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-alt);
    color: var(--text-color);
    transition: all 0.3s ease;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
    width: 300px;
}

.search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1002;
    display: none;
    padding: 0.5rem 0;
}

.search-result-item {
    padding: 0.5rem 1rem;
}

.search-result-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.search-result-link:hover,
.search-result-link:focus {
    background-color: var(--background-alt);
    color: var(--primary-color);
    outline: none;
}

.result-title {
    flex: 1;
}

.result-type {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    border-radius: 12px;
    margin-left: 1rem;
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

.loading-indicator {
    position: absolute;
    right: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    color: var(--text-muted);
}

.loading-indicator.active {
    display: block;
}

.search-results.active {
    display: block;
}

.search-button {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    background: none;
    border: none;
    padding: 0 0.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.loading-indicator {
    position: absolute;
    right: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    color: var(--text-muted);
    animation: spin 1s linear infinite;
}

.loading-indicator.active {
    display: block;
}

@keyframes spin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

.search-button:hover {
    color: var(--primary-color);
}

.search-button i {
    font-size: 1rem;
}


.theme-switch-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-color);
    padding: 0.5rem;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon {
    display: inline-block;
}

/* Hide one icon based on theme */
body.light-theme .moon-icon { display: none; }
body.dark-theme .sun-icon { display: none; }

.language-selector select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background-alt);
    color: var(--text-color);
    cursor: pointer;
}

/* Dropdown Menu Styles */
.has-dropdown > a i { /* Style the down arrow */
    margin-left: 0.3rem;
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.has-dropdown:hover > a i {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%; /* Position below the parent */
    left: 0;
    background-color: var(--background-alt);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    min-width: 180px; /* Adjust as needed */
    z-index: 1001; /* Ensure it's above other content */
}

.has-dropdown:hover .dropdown-menu,
.has-dropdown:focus-within .dropdown-menu { /* Show on hover/focus */
    display: block;
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu li a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-menu li a:hover,
.dropdown-menu li a:focus {
    background-color: var(--primary-color-light);
    color: var(--primary-color);
}

.dropdown-menu li a::after { /* Remove underline effect from main nav */
    display: none;
}


/* Mega Menu Styles (Existing) */
.has-mega-menu .mega-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* Full width relative to viewport or container */
    min-width: 600px; /* Minimum width */
    background-color: var(--background-alt);
    border: 1px solid var(--border-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    padding: 1.5rem;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.has-mega-menu:hover .mega-menu,
.has-mega-menu:focus-within .mega-menu {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mega-menu-content {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.menu-section {
    flex: 1;
}

.menu-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color-light);
    padding-bottom: 0.5rem;
}

.menu-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-section ul li {
    margin-bottom: 0.75rem;
}

.menu-section ul li a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.menu-section ul li a:hover {
    color: var(--primary-color);
}

.menu-section.featured {
    background-color: var(--background-color); /* Slightly different background */
    padding: 1rem;
    border-radius: 4px;
    flex-basis: 25%; /* Adjust width as needed */
}

.feature-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
}

.feature-icon {
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    /* Add background images for icons */
}

.quality-icon { background: url('/assets/icons/quality.svg') no-repeat center center; background-size: contain; }
.time-icon { background: url('/assets/icons/time.svg') no-repeat center center; background-size: contain; }

.menu-section.featured .btn {
    margin-top: 1rem;
    display: inline-block;
}


/* Breadcrumbs */
.breadcrumbs-container {
    background-color: var(--background-alt);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-light);
    font-size: 0.9rem;
}

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

.breadcrumbs li {
    margin-right: 0.5rem;
}

.breadcrumbs li::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--text-muted);
}

.breadcrumbs li:last-child::after {
    content: ''; /* Remove trailing slash */
}

.breadcrumbs a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .current-page {
    color: var(--text-color);
    font-weight: 500;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none; /* Hidden on larger screens */
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger-icon {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    position: relative;
    transition: background-color 0.3s ease;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    left: 0;
    transition: transform 0.3s ease, top 0.3s ease;
}

.hamburger-icon::before {
    top: -8px;
}

.hamburger-icon::after {
    top: 8px;
}

/* Mobile Menu Active State (example) */
.main-nav.active .hamburger-icon {
    background-color: transparent; /* Hide middle bar */
}

.main-nav.active .hamburger-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.main-nav.active .hamburger-icon::after {
    top: 0;
    transform: rotate(-45deg);
}


/* Responsive Styles */
@media (max-width: 992px) {
    .header-actions {
        margin-left: 1rem; /* Reduce space */
    }
    .nav-list li {
        margin-left: 1rem;
    }
    .search-input {
        width: 120px;
    }
}


@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block; /* Show toggle button */
        order: 3; /* Move toggle to the end */
        margin-left: 1rem;
    }

    .nav-list {
        display: none; /* Hide nav list by default */
        position: absolute;
        top: 100%; /* Position below header */
        left: 0;
        right: 0;
        background-color: var(--background-alt);
        flex-direction: column;
        padding: 1rem 0;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    .main-nav.active .nav-list {
        display: flex; /* Show nav list when active */
    }

    .nav-list li {
        margin: 0;
        text-align: center;
    }

    .nav-list li a {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color-light);
    }
     .nav-list li:last-child a {
        border-bottom: none;
    }

    .nav-link::after {
        display: none; /* Hide underline effect on mobile */
    }

    .header-actions {
        order: 2; /* Actions before toggle */
        margin-left: auto; /* Push actions to the right */
    }

    /* Hide dropdowns/mega menus on mobile nav list, handle differently */
    .has-dropdown .dropdown-menu,
    .has-mega-menu .mega-menu {
        display: none !important; /* Force hide in mobile nav list */
        /* Mobile dropdowns might need a different JS/CSS approach (e.g., accordion) */
    }
     /* Basic mobile dropdown toggle - requires JS */
    .has-dropdown > a i {
        display: inline-block; /* Ensure arrow is visible */
    }
    .dropdown-menu { /* Adjust mobile dropdown appearance */
        position: static;
        box-shadow: none;
        border: none;
        background-color: var(--background-color); /* Slightly different bg */
        padding-left: 1rem; /* Indent items */
        display: none; /* Hide by default, toggle with JS */
    }
     .has-dropdown.open .dropdown-menu {
        display: block;
    }
     .dropdown-menu li a {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }

}

@media (max-width: 576px) {
    .logo a {
        font-size: 1.5rem;
    }
    .header-actions {
        flex-wrap: wrap; /* Allow actions to wrap */
        justify-content: flex-end;
    }
    .search-container {
        margin-right: 0.5rem;
        margin-bottom: 0.5rem; /* Add space if wraps */
        width: calc(100% - 80px); /* Adjust width */
    }
    .theme-switch-btn, .language-selector {
        margin-right: 0.5rem;
    }
    .mobile-menu-toggle {
        margin-left: 0.5rem;
    }
}
