/* Hidden class */
.hidden {
    display: none !important;
}

/* Search Container */
.search-container {
    position: relative;
    display: none;
    width: 250px;
}

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

/* Search Input */
.search-input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

/* Search input when navbar is scrolled */
.navbar.scrolled .search-input {
    border: 2px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
}

.search-input:focus {
    outline: none;
    border-color: var(--white);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Focus styles for scrolled navbar */
.navbar.scrolled .search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 26, 48, 0.1);
}

.navbar.scrolled .search-input::placeholder {
    color: var(--text-light);
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.search-results {
    padding: 0.5rem 0;
}

.search-result {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--bg-light);
}

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

.search-result:hover,
.search-result.selected {
    background-color: var(--bg-light);
}

.search-result-image {
    width: 50px;
    height: 50px;
    margin-right: 1rem;
    border-radius: 0;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-light);
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--primary-color);
    color: var(--white);
}

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

.search-result-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 0.25rem 0;
    line-height: 1.2;
}

.search-result-price {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 0.25rem;
}

.search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

.search-view-all {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    background: var(--background-light);
}

.search-view-all-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.search-view-all-link:hover {
    color: var(--primary-dark);
}

/* Mobile Search Container in Hamburger Menu */
.mobile-search-container {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-search-container .search-input {
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-radius: 0;
}

.mobile-search-container .search-input:focus {
    border-color: var(--white);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.mobile-search-container .search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Mobile Search Trigger */
.mobile-search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1002;
}

.mobile-search-trigger:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.navbar.scrolled .mobile-search-trigger {
    color: var(--text-color);
}

/* Mobile Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}


/* Mobile Menu Search Dropdown */
.mobile-search-container .search-dropdown {
    position: static;
    margin-top: 0.5rem;
    border: none;
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-height: 300px;
    background: var(--bg-color);
}

/* Scrollbar Styling for Dropdown */
.search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-dropdown::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 3px;
}

.search-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.search-group-header {
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    background: var(--bg-light, #f5f5f5);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.search-group-more {
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.search-group-more a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
}

.search-group-more a:hover {
    text-decoration: underline;
}

.search-result .highlight {
    background: rgba(8, 26, 48, 0.1);
    font-weight: 600;
}

/* Animation for dropdown appearance */
@keyframes searchDropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-dropdown {
    animation: searchDropdownSlide 0.2s ease-out;
}

/* Focus states for accessibility */
.search-result:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* Loading state */
.search-loading {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
}

.search-loading::after {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid var(--text-light);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}