/**
 * ============================================
 * SEARCH.CSS
 * ============================================
 * Product Search Page Styles
 * Google-inspired clean search interface
 */

/* CSS Variables */
:root {
    /* Colors */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --recommendation-color: #10b981;
    --recommendation-hover: #059669;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #6366f1;

    /* Shadows */
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius: 0.75rem;
    --radius-lg: 1rem;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.hidden {
    display: none !important;
}

/* Header */
.main-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.service-status {
    display: flex;
    gap: 1.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-color);
    animation: pulse 2s infinite;
}

.status-indicator.healthy .status-dot {
    background: var(--success-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tab Navigation */
.tab-navigation {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tab-list {
    display: flex;
    gap: 0;
    padding: 0;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-button:hover {
    color: var(--text-primary);
    background: var(--background);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--background);
}

.tab-button[data-tab="chat-recommendations"].active {
    color: var(--recommendation-color);
    border-bottom-color: var(--recommendation-color);
}

.tab-icon {
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   GOOGLE-STYLE PRODUCT SEARCH INTERFACE
   ============================================ */

.search-page {
    min-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem;
    max-width: 900px;
    margin: 0 auto;
}

/* Search Header */
.search-header {
    text-align: center;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
}

.search-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease-in;
}

.search-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.search-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Search Bar Container */
.search-bar-container {
    width: 100%;
    max-width: 700px;
    margin-bottom: 2rem;
}

.search-form {
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2rem;
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.search-input-wrapper:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
    padding: 0.25rem 0.5rem;
}

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

.clear-search-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    margin-right: 0.5rem;
}

.clear-search-btn:hover {
    background: var(--background);
    color: var(--text-secondary);
}

.search-submit-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    position: relative;
    width: 40px;
    height: 40px;
}

.search-submit-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.search-submit-btn:active {
    transform: scale(0.95);
}

.search-submit-btn .search-icon {
    transition: opacity 0.2s;
}

.search-submit-btn.loading .search-icon {
    opacity: 0;
}

.search-submit-btn .spinner {
    position: absolute;
    width: 20px;
    height: 20px;
}

.spinner {
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Session Info */
.search-session-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.session-label {
    font-weight: 500;
}

.session-id {
    font-family: 'Courier New', monospace;
    color: var(--text-light);
    font-size: 0.8rem;
}

.clear-session-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.clear-session-btn:hover {
    background: var(--background);
    border-color: var(--text-secondary);
}

/* Loading State */
.search-loading {
    text-align: center;
    padding: 3rem 1rem;
    animation: fadeIn 0.3s ease-in;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

.search-loading p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Results Container */
.search-results {
    width: 100%;
    animation: fadeIn 0.5s ease-in;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.results-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
}

/* Products Grid */
.products-grid {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* Product Card */
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    max-height: 80px;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.product-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.product-content {
    flex: 1;
    min-width: 0;
}

.product-header {
    margin-bottom: 0.25rem;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
    line-height: 1.2;
}

.product-description {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.2;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.product-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.meta-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-light);
    font-weight: 500;
}

.meta-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.meta-value.price {
    color: var(--success-color);
    font-size: 0.95rem;
}

.meta-value.stock {
    color: var(--primary-color);
}

.meta-value.low-stock {
    color: var(--warning-color);
}

.meta-value.out-of-stock {
    color: var(--error-color);
}

.meta-value.expiration {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* No Results State */
.no-results {
    text-align: center;
    padding: 4rem 1rem;
    animation: fadeIn 0.3s ease-in;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-secondary);
}

/* Error State */
.search-error {
    text-align: center;
    padding: 4rem 1rem;
    animation: fadeIn 0.3s ease-in;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.search-error h3 {
    font-size: 1.5rem;
    color: var(--error-color);
    margin-bottom: 0.5rem;
}

.search-error p {
    color: var(--text-secondary);
}

/* Product Details Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    margin-right: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem 2rem 2rem;
}

/* Toast Messages */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 400px;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.error-toast {
    background: var(--error-color);
    color: white;
}

.success-toast {
    background: var(--success-color);
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .service-status {
        justify-content: center;
    }

    .tab-list {
        justify-content: center;
    }

    .tab-button {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        transform: translateY(-100px);
        max-width: none;
    }

    .toast.show {
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .search-header {
        margin-top: 2rem;
    }

    .search-logo {
        font-size: 3rem;
    }

    .search-title {
        font-size: 1.5rem;
    }

    .product-card {
        flex-direction: column;
    }

    .product-icon {
        font-size: 2.5rem;
    }

    .product-meta {
        gap: 1rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
