/* ============================================
   HEADER SEARCH BAR
   Search in navigation header on all pages
   ============================================ */

.header-search {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    padding: 8px 16px;
    margin: 0 20px;
    flex: 0 1 300px;
    transition: all 0.3s ease;
}

.header-search:focus-within {
    border-color: var(--primary-color, #8B4513);
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.15);
}

.header-search i {
    color: #999;
    font-size: 16px;
    margin-right: 10px;
}

.header-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: #333;
    background: transparent;
    width: 100%;
}

.header-search input::placeholder {
    color: #999;
}

/* Adjust navbar layout */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 15px 20px;
}

.logo {
    flex: 0 0 auto;
}

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    justify-content: flex-end;
}

/* Search results dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

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

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

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

.search-result-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 2px;
}

.search-result-price {
    color: var(--primary-color, #8B4513);
    font-size: 13px;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: #999;
}

.search-no-results i {
    font-size: 32px;
    margin-bottom: 10px;
    display: block;
}

/* Mobile responsive */
@media (max-width: 1024px) {
    .header-search {
        flex: 0 1 200px;
        margin: 0 10px;
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 15px 20px;
        position: relative;
    }
    
    .logo {
        flex: 0 0 auto;
        order: 1;
    }
    
    .nav-toggle {
        flex: 0 0 auto;
        order: 3;
        z-index: 10;
    }
    
    .header-search {
        display: none; /* Hide search on mobile to save space */
    }
    
    .nav-links {
        position: absolute;
        top: 100%;
        right: 1.5rem;
        background: rgba(255, 255, 255, 0.96);
        padding: 1.5rem;
        border-radius: var(--radius-md);
        display: grid;
        gap: 1.25rem;
        min-width: 220px;
        border: 1px solid rgba(45, 38, 32, 0.12);
        box-shadow: 0 18px 32px rgba(69, 53, 39, 0.14);
        transform-origin: top right;
        transform: scale(0.9);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease, transform 0.25s ease;
        flex-direction: column;
        gap: 1.25rem;
        width: auto;
        order: 2;
        z-index: 5;
    }
    
    .nav-links[data-visible="true"] {
        opacity: 1;
        transform: scale(1);
        pointer-events: auto;
    }
    
    .search-dropdown {
        max-height: 300px;
    }
}

/* Loading state */
.header-search.loading::after {
    content: '';
    position: absolute;
    right: 16px;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color, #8B4513);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* View all results link */
.search-view-all {
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.search-view-all a {
    color: var(--primary-color, #8B4513);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.search-view-all a:hover {
    text-decoration: underline;
}
