/**
 * Mobile Search Overlay
 * Full-screen search with suggestions
 */

:root {
    --search-overlay-bg: rgba(0, 0, 0, 0.5);
    --search-header-bg: #ffffff;
    --search-text-color: #333333;
    --search-border-color: #dddddd;
    --search-accent-color: var(--toolkit-primary, #d32f2f);
    --search-input-bg: #ffffff;
}

/* Overlay */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--search-overlay-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Container */
.mobile-search-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

/* Search Form */
.mobile-search-form-wrapper {
    padding: 20px 16px;
    background: var(--search-header-bg);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--search-input-bg);
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}


.search-icon {
    position: absolute;
    right: 60px;
    width: 20px;
    height: 20px;
    color: #999999;
    pointer-events: none;
    z-index: 1;
}

.mobile-search-input {
    flex: 1;
    width: 100%;
    padding: 14px 50px 14px 44px;
    border: none;
    font-size: 15px;
    background: transparent;
    color: var(--search-text-color);
}

.mobile-search-input:focus {
    outline: none;
}

.mobile-search-input::placeholder {
    color: #999999;
}

.mobile-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 2px;
    border: none;
    background: transparent;
    color: #666666;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
}

.mobile-search-close:hover,
.mobile-search-close:focus {
    background: rgba(0, 0, 0, 0.05);
    color: var(--search-text-color);
}

.mobile-search-close svg {
    width: 20px;
    height: 20px;
}

/* Content Area */
.mobile-search-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--search-header-bg);
    -webkit-overflow-scrolling: touch;
}

/* Loading State */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--search-border-color);
    border-top-color: var(--search-accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-loading p {
    margin: 16px 0 0;
    color: #666666;
}

/* Section Headers */
.search-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.search-section-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--search-text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-recent {
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--search-accent-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* Suggestions */
.search-suggestions {
    margin-bottom: 24px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s ease;
    margin-bottom: 8px;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.suggestion-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.suggestion-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--search-text-color);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.suggestion-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--search-accent-color);
}

/* Recent Searches */
.search-recent {
    margin-bottom: 24px;
}

.recent-searches-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recent-search-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.recent-search-item:hover {
    background: #f8f9fa;
}

.recent-search-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    color: #999999;
}

.recent-search-text {
    flex: 1;
    font-size: 14px;
    color: var(--search-text-color);
}

.remove-recent {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: #999999;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.remove-recent:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Popular Products */
.search-popular {
    margin-bottom: 24px;
}

.popular-products-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.popular-product-item {
    display: block;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.popular-product-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.popular-product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.popular-product-info {
    padding: 8px;
}

.popular-product-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--search-text-color);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.popular-product-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--search-accent-color);
}

/* Empty State */
.search-empty {
    text-align: center;
    padding: 40px 20px;
}

.search-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: #cccccc;
}

.search-empty p {
    font-size: 14px;
    color: #666666;
    margin: 0;
}

/* Accessibility */
.mobile-search-overlay:focus-within .mobile-search-close:focus {
    outline: 2px solid var(--search-accent-color);
    outline-offset: 2px;
}

/* Dark Mode Support */
/* @media (prefers-color-scheme: dark) {
    :root {
        --search-overlay-bg: rgba(0, 0, 0, 0.8);
        --search-header-bg: #1a1a1a;
        --search-text-color: #e0e0e0;
        --search-border-color: #404040;
        --search-input-bg: #2a2a2a;
    }
    
    .suggestion-item:hover,
    .recent-search-item:hover {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .popular-product-item {
        background: #2a2a2a;
    }
} */

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .mobile-search-overlay,
    .suggestion-item,
    .popular-product-item {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}
