/* SearchEngine - Modern Clean UI */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #e74c3c;
}

.product-count {
    color: #e74c3c;
    font-size: 14px;
    font-weight: 500;
}

.fold-btn {
    padding: 6px 20px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.fold-btn:hover {
    background: #f5f5f5;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 10px;
    padding: 20px 30px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
}

.tenant-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tenant-input-wrapper label {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

#tenantInput,
#skuFilterDimension {
    width: 120px;
    padding: 10px 15px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

#tenantInput:focus,
#skuFilterDimension:focus {
    border-color: #e74c3c;
}

#searchInput {
    flex: 1;
    padding: 10px 15px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

#searchInput:focus {
    border-color: #e74c3c;
}

.search-btn {
    padding: 10px 30px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: #c0392b;
}

/* Filter Section */
.filter-section {
    padding: 15px 30px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.filter-section.hidden {
    display: none;
}

.filter-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 15px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    min-width: 90px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-tag {
    padding: 6px 15px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tag:hover {
    background: #e8e8e8;
}

.filter-tag.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.filter-dropdowns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-dropdowns select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    outline: none;
}

.clear-filters-btn {
    padding: 6px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.clear-filters-btn:hover {
    background: #c0392b;
}

/* Sort Section */
.sort-section {
    display: flex;
    align-items: center;
    padding: 15px 30px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    gap: 10px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sort-btn:hover {
    background: #f8f8f8;
}

.sort-btn.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    gap: 0;
    font-size: 10px;
    line-height: 1;
    margin-left: 4px;
}

.arrow-up, .arrow-down {
    cursor: pointer;
    padding: 2px 4px;
    transition: all 0.2s;
    opacity: 0.4;
    border-radius: 2px;
}

.arrow-up:hover, .arrow-down:hover {
    opacity: 0.7;
    background: rgba(231, 76, 60, 0.1);
}

.arrow-up.active, .arrow-down.active {
    opacity: 1;
    color: #e74c3c;
    font-weight: bold;
    background: rgba(231, 76, 60, 0.15);
}

.sort-right {
    margin-left: auto;
}

.sort-right select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    background: white;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #e74c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: #666;
    font-size: 14px;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 30px;
    background: #f8f8f8;
    min-height: 400px;
}

.product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.product-image-wrapper {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}

.product-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f39c12;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}

.product-price {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 8px;
}

.product-moq {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.product-quantity {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.product-title {
    font-size: 13px;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 36px;
    margin-bottom: 8px;
}

.product-meta {
    font-size: 11px;
    color: #999;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.product-time {
    font-size: 10px;
    color: #aaa;
    margin-top: 4px;
    font-style: italic;
}

.product-label {
    display: inline-block;
    background: #e74c3c;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    margin-top: 6px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 30px;
    background: white;
}

.page-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #f8f8f8;
    border-color: #e74c3c;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.page-info {
    font-size: 14px;
    color: #666;
    padding: 0 15px;
}

/* Debug Info */
.debug-info {
    margin: 20px 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
}

.debug-info summary {
    padding: 12px 15px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    color: #666;
}

.debug-info summary:hover {
    background: #f0f0f0;
}

.query-info-content {
    padding: 15px;
    border-top: 1px solid #ddd;
    font-size: 13px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.info-item {
    padding: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.info-item strong {
    display: block;
    color: #e74c3c;
    margin-bottom: 6px;
    font-size: 12px;
}

.info-item span {
    color: #333;
    font-size: 13px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    background: #333;
    color: white;
    font-size: 13px;
}

footer span {
    color: #e74c3c;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 80px 20px;
    background: white;
    color: #666;
}

.no-results h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #999;
}

/* Error Message */
.error-message {
    background: #ffe6e6;
    color: #c0392b;
    padding: 20px;
    margin: 30px;
    border-radius: 8px;
    border-left: 4px solid #e74c3c;
}

.error-message strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .top-header {
        padding: 12px 15px;
    }
    
    .search-bar {
        padding: 15px;
    }
    
    .filter-section {
        padding: 12px 15px;
    }
    
    .filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .filter-label {
        min-width: auto;
    }
    
    .sort-section {
        padding: 12px 15px;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
        padding: 15px;
    }
    
    .pagination {
        padding: 20px 15px;
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-left {
        gap: 15px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .product-count {
        font-size: 12px;
    }
}
