header {
    background: #f3f3f3;
    position: fixed !important;
    top: 0 !important;
    left: 0;
    width: 100%;
    z-index: 1000;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    will-change: top;
    height: auto;
    min-height: 60px;
}

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

header.navbar-hidden {
    top: -100px !important;
}

header.navbar-visible {
    top: 0 !important;
}

/* Ensure navbar is always visible by default */
header:not(.navbar-hidden) {
    top: 0;
}

/* Add body padding to account for fixed header */
body {
    padding-top: 72px;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    letter-spacing: -0.6px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
    font-size: 1.5rem;
    color: #8B4513;
}

.logo img {
    width: 128px;
    height: 40px;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #2c3e50;
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: #8B4513;
    border-bottom-color: #8B4513;
}

.search-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.search-popup-overlay.active {
    visibility: visible;
    opacity: 1;
}

.search-popup-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.search-input-container {
    position: relative;
    flex: 1;
}

#search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem; /* Right padding for icon */
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    background: white;
    font-family: 'Inter', sans-serif;
}

#search-input:focus {
    border-color: #8B4513;
}

.search-icon-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #8B4513;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.search-icon-btn:hover {
    color: #5a4b3a;
}

.search-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
    flex-shrink: 0;
}

.search-close-btn:hover {
    color: #333;
}

.search-dropdown {
    position: static;
    margin-top: 1rem;
    max-height: 400px;
    overflow-y: auto;
    border: none;
    border-radius: 8px;
    box-shadow: none;
    background: white;
}

.search-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.search-result-item.unavailable {
    opacity: 0.6;
}

.search-result-item.unavailable .search-result-name,
.search-result-item.unavailable .search-result-category {
    color: #999;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-image {
    flex-shrink: 0;
    width: 64px !important;
    height: 64px !important;
    overflow: hidden;
    position: relative;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.search-result-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-result-item:hover .search-result-image img {
    transform: scale(1.05);
}

.search-result-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ddd;
    color: #666;
    font-size: 10px;
    text-align: center;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-unavailable {
    font-size: 0.7rem;
    color: #dc3545;
    margin-top: 0.2rem;
    font-weight: 500;
}

.search-result-name {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.2rem;
}

.search-result-category {
    font-size: 0.8rem;
    color: #8B4513;
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.cart-menu {
    position: relative;
}

.cart-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s ease;
    color: #2c3e50;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-btn:hover {
    background: #f8f9fa;
}

.cart-count {
    position: absolute;
    top: 0;
    right: 0;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
    min-width: 250px;
    max-width: 300px;
    display: none;
    z-index: 102;
    max-height: 400px;
    overflow-y: auto;
}

.cart-dropdown-content {
    padding: 1rem;
}

.cart-dropdown-content h4 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.cart-summary p {
    margin: 0.5rem 0;
    color: #666;
}

.view-cart-btn {
    background: #8B4513;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    transition: background 0.3s ease;
}

.view-cart-btn:hover {
    background: #5a4b3a;
}

.account-menu {
    position: relative;
}

.account-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s ease;
    color: #2c3e50;
}

.account-btn:hover {
    background: #f8f9fa;
}

.account-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
    min-width: 120px;
    display: none;
    z-index: 101;
}

.account-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #2c3e50;
    transition: background 0.3s ease;
}

.account-dropdown a:hover {
    background: #f8f9fa;
}

.register-link {
    font-weight: 600;
    color: #8B4513;
}

/* Hamburger menu for mobile */
.hamburger {
    display: none;
    color: #2c3e50;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    min-width: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: center;
}

.hamburger:hover {
    color: #8B4513;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    body {
        padding-top: 60px;
    }

    .search-popup-overlay {
        padding-top: 80px;
    }

    .nav-links {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 200px;
        background: #f3f3f3;
        flex-direction: column;
        gap: 0;
        padding: 2rem;
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.3s ease;
        z-index: 99;
    }

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

    .nav-links a {
        padding: 1rem 0;
        font-size: 1.2rem;
        width: 100%;
        text-align: center;
        border-bottom: 1px solid rgba(139, 69, 19, 0.1);
    }

    nav {
        padding: 1rem;
    }

    .logo img {
        width: 100px;
        height: 32px;
    }

    .user-menu {
        gap: 0.25rem;
    }

    .search-popup-content {
        width: 95%;
        padding: 1rem;
    }

    .search-header {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    nav {
        padding: 0.75rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .logo img {
        width: 80px;
        height: 26px;
    }

    .shopping-cart svg {
        width: 20px;
        height: 20px;
    }

    .cart-count {
        width: 16px;
        height: 16px;
        font-size: 11px;
    }

    .account-btn svg {
        width: 20px;
        height: 20px;
    }

    .nav-links {
        padding: 1rem;
        top: 64px;
    }

    .search-popup-content {
        max-width: none;
    }
}
