/* Layout CSS - Header, Navigation, Footer, and Mobile Responsiveness */

/* Header Styles */
header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

/* Navigation */
nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 5%;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Navigation Row 1 - Logo (left) | Theme Toggle (right) - Bottom aligned */
.nav-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;  /* Bottom align */
    width: 100%;
}

/* Navigation Row 2 - Menu (left) | Search (right) - Bottom aligned */
.nav-row-2 {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;  /* Bottom align */
    width: 100%;
}

/* Header Search Container - Aligned to right, height matches menu text */
.header-search-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;  /* Reduced vertical padding to match menu text height */
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: var(--transition);
    max-width: 390px;  /* Reduced by 10px */
    width: 100%;
    margin-right: 20px;  /* Shift left by 20px */
    height: auto;
}

.header-search-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Search Icon Button (clickable) */
.search-icon-button {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text-color);
    transition: var(--transition);
    border-radius: 4px;
}

.search-icon-button:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
}

.search-icon-button svg {
    width: 20px;
    height: 20px;
}

/* Header Search Input */
.header-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9rem;  /* Slightly smaller to match menu text */
    color: var(--text-color);
    outline: none;
    font-family: var(--font-family);
    min-width: 0;
    line-height: 1.5;
    padding: 0.1rem 0;
}

.header-search-input::placeholder {
    color: #999999;
    opacity: 1;
}

/* Header Search Clear Button */
.header-search-clear-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text-color);
    transition: var(--transition);
    border-radius: 4px;
}

.header-search-clear-btn:hover {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
}

.header-search-clear-btn svg {
    width: 16px;
    height: 16px;
}

/* Mobile Menu Toggle - Hidden on desktop */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

/* Logo */
.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
    justify-self: start;
}

.logo:hover {
    transform: scale(1.05);
}

/* Navigation Links */
.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
    align-items: flex-end;  /* Bottom align with search */
}

.nav-links li {
    margin: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    font-size: 1rem;
    line-height: 1.5;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: var(--transition);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.theme-toggle:hover {
    background-color: var(--primary-color);
    transform: scale(1.1);
}

.theme-icon {
    font-size: 1.2rem;
    transition: var(--transition);
}

.theme-toggle::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: var(--white);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
}

.theme-toggle:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Footer */
footer {
    background-color: #1f2937;
    color: var(--footer-text-color);
    text-align: center;
    padding: 2rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    margin: 3px 0;
    transition: var(--transition);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Mobile header height adjustment */
    :root {
        --header-height: 70px;  /* Mobile header (shorter) + 5px margin */
    }

    nav {
        padding: 0.75rem 5%;
        gap: 0.5rem;
    }

    /* Hide theme toggle and search on mobile */
    .theme-style-toggle,
    .header-search-container {
        display: none;
    }

    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }

    /* Navigation row 2 - becomes vertical on mobile */
    .nav-row-2 {
        flex-direction: column;
        align-items: stretch;
    }

    /* Navigation links - collapsible mobile menu */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--white);
        flex-direction: column;
        padding: 1rem;
        box-shadow: var(--shadow);
        gap: 0.5rem;
        align-items: stretch;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links a {
        display: block;
        padding: 0.75rem 1rem;
        border-radius: 6px;
        transition: var(--transition);
    }

    .nav-links a:hover {
        background-color: var(--light-bg);
    }

    .logo {
        font-size: 1.2rem;
    }
}
