/**
 * Live Search Styles
 * Responsive, modern search modal with smooth animations
 */

/* Search Overlay (Full-screen backdrop) */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 20px 20px;
    overflow-y: auto;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.search-overlay.hidden {
    display: none;
    opacity: 0;
}

/* Search Modal */
.search-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Search Header */
.search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.search-input {
    flex: 1;
    font-size: 18px;
    border: none;
    outline: none;
    padding: 8px 0;
    color: #111827;
    font-family: inherit;
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #6b7280;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-close:hover {
    color: #111827;
}

/* Search Content */
.search-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 24px;
    max-height: calc(100vh - 220px);
}

/* Autocomplete Suggestions */
.search-suggestions {
    margin-bottom: 16px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    color: #374151;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: #f3f4f6;
}

.suggestion-item svg {
    color: #9ca3af;
    flex-shrink: 0;
}

.suggestion-item span {
    flex: 1;
    font-size: 15px;
}

.suggestion-item strong {
    color: #111827;
    font-weight: 600;
}

/* Search Results */
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.search-results-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.search-time {
    font-size: 13px;
    color: #9ca3af;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    .search-results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Product Card (in search results) */
.search-product-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-product-card .product-image {
    position: relative;
    padding-bottom: 133%; /* 3:4 aspect ratio */
    background: #f9fafb;
    overflow: hidden;
}

.search-product-card .product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.search-product-card:hover .product-image img {
    transform: scale(1.05);
}

.search-product-card .product-info {
    padding: 12px 8px;
}

.search-product-card h4 {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-product-card p {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 6px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-product-card .product-attributes {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Search Results Footer */
.search-results-footer {
    margin-top: 24px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.btn-view-all {
    display: inline-block;
    padding: 12px 24px;
    background: #111827;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-view-all:hover {
    background: #1f2937;
}

/* Recent Searches */
.recent-searches h3 {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

.recent-searches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recent-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #374151;
}

.recent-search-item:hover {
    background: #fff;
    border-color: #d1d5db;
    transform: translateY(-1px);
}

.recent-search-item svg {
    color: #9ca3af;
    flex-shrink: 0;
}

/* Loading State */
.search-loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #e5e7eb;
    border-top-color: #111827;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.search-loading p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* No Results */
.search-no-results {
    text-align: center;
    padding: 60px 20px;
}

.search-no-results p {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-overlay {
        padding: 20px 12px 12px;
    }

    .search-modal {
        max-height: calc(100vh - 40px);
        border-radius: 8px;
    }

    .search-header {
        padding: 16px;
    }

    .search-input {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .search-content {
        padding: 12px 16px 16px;
    }

    .search-results-grid {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .search-product-card h4 {
        font-size: 13px;
    }

    .search-product-card p,
    .search-product-card .product-attributes {
        font-size: 11px;
    }
}
