/* =================================
    CSS VARIABLES (Light & Dark Mode)
    ================================= */
:root {
    /* Light Mode */
    --header-background: #f8f8f8;
    --header-text-color: #000;
    --search-container-background: white;
    --search-container-border: black;
    --search-dropdown-background: white;
    --search-dropdown-border: #ddd;
    --search-item-hover-background: #f0f0f0;
    --search-item-hover-text: #000;
    --nav-button-background: #f8f8f8;
    --nav-button-text: black;
    --nav-button-border: #3d435c;
    --nav-button-hover-background: #62707D;
    --nav-button-hover-text: white;
    --search-button-background: #f8f8f8;
    --search-button-icon-color: #000;
    --search-button-hover-background: #62707D;
    --search-button-hover-icon-color: white;
    --select-border-right: 1px solid #ccc;
    --theme-toggle-icon-color: #000;
    --theme-toggle-icon-hover: #62707D;
}

/* Dark Mode - Activated by System Preference or Manual Toggle */
@media (prefers-color-scheme: dark) {
    :root {
        --header-background: #1a1a1a;
        --header-text-color: #e0e0e0;
        --search-container-background: #2a2a2a;
        --search-container-border: #555;
        --search-dropdown-background: #2a2a2a;
        --search-dropdown-border: #444;
        --search-item-hover-background: #3a3a3a;
        --search-item-hover-text: #e0e0e0;
        --nav-button-background: #1a1a1a;
        --nav-button-text: #e0e0e0;
        --nav-button-border: #62707d;
        --nav-button-hover-background: #444;
        --nav-button-hover-text: #e0e0e0;
        --search-button-background: #1a1a1a;
        --search-button-icon-color: #e0e0e0;
        --search-button-hover-background: #444;
        --search-button-hover-icon-color: #e0e0e0;
        --select-border-right: 1px solid #555;
        --theme-toggle-icon-color: #e0e0e0;
        --theme-toggle-icon-hover: #6a9ce0;
    }
}

body[data-theme='dark'] {
    --header-background: #1a1a1a;
    --header-text-color: #e0e0e0;
    --search-container-background: #2a2a2a;
    --search-container-border: #555;
    --search-dropdown-background: #2a2a2a;
    --search-dropdown-border: #444;
    --search-item-hover-background: #3a3a3a;
    --search-item-hover-text: #e0e0e0;
    --nav-button-background: #1a1a1a;
    --nav-button-text: #e0e0e0;
    --nav-button-border: #62707d;
    --nav-button-hover-background: #444;
    --nav-button-hover-text: #e0e0e0;
    --search-button-background: #1a1a1a;
    --search-button-icon-color: #e0e0e0;
    --search-button-hover-background: #444;
    --search-button-hover-icon-color: #e0e0e0;
    --select-border-right: 1px solid #555;
    --theme-toggle-icon-color: #e0e0e0;
    --theme-toggle-icon-hover: #6a9ce0;
}

/* =================================
    General Header Styling
    ================================= */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 80px;
    /* Removed !important flag */
    background-color: var(--header-background);
    color: var(--header-text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 10000;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1800px;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    border: 0 !important;
    white-space: nowrap !important;
}

/* Search Container */
.search-container {
    display: flex;
    align-items: center;
    background-color: var(--search-container-background);
    padding: 5px;
    border-radius: 5px;
    flex-grow: 1;
    max-width: 700px;
    position: relative;
    border: 1px solid var(--search-container-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.search-container input[type="text"] {
    flex-grow: 1;
    padding: 8px;
    font-size: 14px;
    border: none;
    outline: none;
    background-color: transparent;
    color: var(--header-text-color);
}

.search-container select {
    background-color: transparent;
    color: var(--header-text-color);
    border: none;
    padding: 8px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    margin-right: 5px;
    border-right: var(--select-border-right);
    border-radius: 0;
}

.search-container button {
    padding: 5px 10px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-left: 5px;
    border-radius: 5px;
    background-color: var(--search-button-background);
    color: var(--search-button-icon-color);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.search-container button svg {
    fill: var(--search-button-icon-color);
    width: 1em;
    height: 1em;
    vertical-align: middle;
    transition: fill 0.2s ease;
}

.search-container button:hover {
    background-color: var(--search-button-hover-background);
    color: var(--search-button-hover-icon-color);
}

.search-container button:hover svg {
    fill: var(--search-button-hover-icon-color);
}

/* Search Dropdown Results */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--search-dropdown-background);
    border: 1px solid var(--search-dropdown-border);
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.home-logo {
    height: 40px;
    width: auto;
}

.search-item {
    padding: 10px;
    cursor: pointer;
    color: var(--header-text-color);
    transition: background-color 0.3s ease;
}

.search-item:hover {
    background-color: var(--search-item-hover-background);
    color: var(--search-item-hover-text);
}

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--search-dropdown-background);
    border: 1px solid var(--search-dropdown-border);
    max-height: 200px;
    overflow-y: auto;
    z-index: 999;
    display: none;
}

#search-results .search-item:hover {
    background-color: var(--search-item-hover-background);
    color: var(--search-item-hover-text); /* Added missing color var */
}

/* --- Navigation Buttons --- */
.nav-buttons button {
    padding: 8px 15px;
    background-color: var(--nav-button-background);
    color: var(--nav-button-text);
    border: 1px solid var(--nav-button-border);
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
    font-weight: bold;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    position: relative;
}

.nav-buttons button:hover {
    background-color: var(--nav-button-hover-background);
    border-color: var(--nav-button-hover-background);
    color: var(--nav-button-hover-text);
}

/* --- Theme Toggle Button --- */
.theme-toggle-container {
    display: flex;
    align-items: center;
    margin-left: 10px;
}

#theme-toggle {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

#theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--theme-toggle-icon-color);
    transition: fill 0.3s ease;
}

#theme-toggle:hover svg {
    fill: var(--theme-toggle-icon-hover);
}