/**
 * OneStop Smart Search - Styles
 *
 * Clean, modern, mobile-responsive search UI
 */

/* Container */
.onestop-search-container {
    position: relative;
    width: 100%;
    max-width: 600px;
}

/* Search input */
.onestop-search-input {
    width: 100%;
    padding: 12px 40px 12px 44px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.onestop-search-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.onestop-search-input.is-loading {
    background-image: none;
}

/* Search icon */
.onestop-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #888;
    pointer-events: none;
}

/* Loading spinner */
.onestop-search-spinner {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #0066cc;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.onestop-search-spinner.active {
    opacity: 1;
    animation: onestop-spin 0.8s linear infinite;
}

@keyframes onestop-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Results dropdown */
.onestop-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.onestop-search-results.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Results header */
.onestop-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    color: #666;
}

.onestop-search-time {
    color: #28a745;
    font-weight: 600;
}

/* Single result item */
.onestop-search-result {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s;
}

.onestop-search-result:last-of-type {
    border-bottom: none;
}

.onestop-search-result:hover,
.onestop-search-result.is-selected {
    background-color: #f5f8ff;
}

/* Product image */
.onestop-search-result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}

.onestop-search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product content */
.onestop-search-result-content {
    flex: 1;
    min-width: 0;
}

.onestop-search-result-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.onestop-search-result-title mark {
    background: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.onestop-search-result-meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.onestop-search-result-meta .sku {
    font-family: monospace;
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 3px;
}

.onestop-search-result-meta .brand {
    color: #0066cc;
}

.onestop-search-result-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.onestop-search-result-price {
    font-weight: 700;
    font-size: 15px;
    color: #28a745;
}

.onestop-search-result-stock {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.onestop-search-result-stock.in-stock {
    background: #d4edda;
    color: #155724;
}

.onestop-search-result-stock.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* View all link */
.onestop-search-viewall {
    display: block;
    padding: 12px 16px;
    text-align: center;
    background: #f8f9fa;
    color: #0066cc;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border-top: 1px solid #eee;
    transition: background-color 0.15s;
}

.onestop-search-viewall:hover {
    background: #e9ecef;
    color: #004499;
}

/* No results */
.onestop-search-no-results {
    padding: 32px 16px;
    text-align: center;
}

.onestop-search-no-results-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.onestop-search-no-results-message {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px;
}

.onestop-search-no-results-suggestion {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* Error */
.onestop-search-error {
    padding: 24px 16px;
    text-align: center;
    color: #dc3545;
    font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .onestop-search-container {
        max-width: 100%;
    }

    .onestop-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 60vh;
        transform: translateY(100%);
    }

    .onestop-search-results.is-open {
        transform: translateY(0);
    }

    .onestop-search-result {
        padding: 16px;
    }

    .onestop-search-result-image {
        width: 50px;
        height: 50px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .onestop-search-input {
        background: #1a1a1a;
        border-color: #333;
        color: #fff;
    }

    .onestop-search-input:focus {
        border-color: #4da6ff;
        box-shadow: 0 0 0 3px rgba(77, 166, 255, 0.2);
    }

    .onestop-search-results {
        background: #1a1a1a;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }

    .onestop-search-header {
        background: #222;
        border-color: #333;
    }

    .onestop-search-result {
        border-color: #333;
    }

    .onestop-search-result:hover,
    .onestop-search-result.is-selected {
        background-color: #252525;
    }

    .onestop-search-result-title {
        color: #fff;
    }

    .onestop-search-result-meta {
        color: #aaa;
    }

    .onestop-search-result-meta .sku {
        background: #333;
    }

    .onestop-search-viewall {
        background: #222;
        border-color: #333;
    }

    .onestop-search-viewall:hover {
        background: #2a2a2a;
    }
}

/* Animation for results appearing */
.onestop-search-result {
    animation: onestop-fadeIn 0.2s ease-out;
    animation-fill-mode: both;
}

.onestop-search-result:nth-child(1) { animation-delay: 0.02s; }
.onestop-search-result:nth-child(2) { animation-delay: 0.04s; }
.onestop-search-result:nth-child(3) { animation-delay: 0.06s; }
.onestop-search-result:nth-child(4) { animation-delay: 0.08s; }
.onestop-search-result:nth-child(5) { animation-delay: 0.10s; }
.onestop-search-result:nth-child(6) { animation-delay: 0.12s; }
.onestop-search-result:nth-child(7) { animation-delay: 0.14s; }
.onestop-search-result:nth-child(8) { animation-delay: 0.16s; }

@keyframes onestop-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Plumbing supply specific styles */
.onestop-search-result-meta .category {
    color: #856404;
}

/* High contrast focus indicators for accessibility */
.onestop-search-input:focus-visible {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

.onestop-search-result:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: -2px;
}

/* ==========================================
   Autocomplete Styles (v2)
   ========================================== */

.onestop-autocomplete-list {
    padding: 8px 0;
}

.onestop-autocomplete-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.onestop-autocomplete-item:hover,
.onestop-autocomplete-item.is-selected {
    background-color: #f5f8ff;
}

.onestop-autocomplete-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.onestop-autocomplete-type {
    font-size: 11px;
    color: #888;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}

/* Empty state */
.onestop-search-empty {
    padding: 24px 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Dark mode autocomplete */
@media (prefers-color-scheme: dark) {
    .onestop-autocomplete-item:hover,
    .onestop-autocomplete-item.is-selected {
        background-color: #252525;
    }

    .onestop-autocomplete-text {
        color: #fff;
    }

    .onestop-autocomplete-type {
        background: #333;
        color: #aaa;
    }

    .onestop-search-empty {
        color: #aaa;
    }
}

/* ==========================================
   Facets & Filters (v2)
   ========================================== */

.onestop-facets {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.onestop-facet-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.onestop-facet-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.onestop-filter-item {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    color: #333;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 14px;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}

.onestop-filter-item:hover {
    background: #e9ecef;
    border-color: #0066cc;
    color: #0066cc;
}

.onestop-filter-item .count {
    color: #888;
    font-size: 11px;
}

.onestop-facet-stock {
    display: flex;
    align-items: center;
}

.onestop-facet-stock label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
}

.onestop-facet-stock input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0066cc;
}

/* Active filters bar */
.onestop-active-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #e3f2fd;
    border-bottom: 1px solid #bbdefb;
}

.onestop-active-filters-label {
    font-size: 12px;
    color: #1565c0;
    font-weight: 500;
}

.onestop-filter-clear {
    padding: 4px 10px;
    font-size: 11px;
    color: #d32f2f;
    background: #fff;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.onestop-filter-clear:hover {
    background: #ffebee;
    border-color: #d32f2f;
}

/* Cached badge */
.onestop-cached-badge {
    display: inline-block;
    padding: 1px 6px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: #7c4dff;
    background: #ede7f6;
    border-radius: 3px;
    margin-left: 6px;
}

/* Empty state hint */
.onestop-search-empty-hint {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
}

/* Dark mode facets */
@media (prefers-color-scheme: dark) {
    .onestop-facets {
        background: #1a1a1a;
        border-color: #333;
    }

    .onestop-facet-title {
        color: #aaa;
    }

    .onestop-filter-item {
        background: #252525;
        border-color: #444;
        color: #ddd;
    }

    .onestop-filter-item:hover {
        background: #333;
        border-color: #4da6ff;
        color: #4da6ff;
    }

    .onestop-filter-item .count {
        color: #777;
    }

    .onestop-facet-stock label {
        color: #ddd;
    }

    .onestop-active-filters {
        background: #1a237e;
        border-color: #283593;
    }

    .onestop-active-filters-label {
        color: #90caf9;
    }

    .onestop-filter-clear {
        background: #2a2a2a;
        border-color: #ef5350;
        color: #ef5350;
    }

    .onestop-filter-clear:hover {
        background: #3a2a2a;
    }

    .onestop-cached-badge {
        background: #311b92;
        color: #b388ff;
    }
}

/* Mobile facets */
@media (max-width: 768px) {
    .onestop-facets {
        padding: 10px 12px;
        gap: 10px;
    }

    .onestop-facet-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .onestop-facet-title {
        width: 100%;
    }

    .onestop-filter-item {
        padding: 6px 12px;
    }
}

/* ==========================================
   Recent Searches
   ========================================== */

.onestop-recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.onestop-recent-clear {
    font-size: 11px;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.onestop-recent-clear:hover {
    background: #eee;
    color: #d32f2f;
}

.onestop-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.onestop-recent-item:last-child {
    border-bottom: none;
}

.onestop-recent-item:hover {
    background-color: #f5f8ff;
}

.onestop-recent-icon {
    font-size: 14px;
    color: #888;
}

.onestop-recent-text {
    font-size: 14px;
    color: #333;
}

/* Dark mode recent searches */
@media (prefers-color-scheme: dark) {
    .onestop-recent-header {
        background: #1a1a1a;
        border-color: #333;
        color: #aaa;
    }

    .onestop-recent-clear:hover {
        background: #333;
    }

    .onestop-recent-item {
        border-color: #333;
    }

    .onestop-recent-item:hover {
        background-color: #252525;
    }

    .onestop-recent-text {
        color: #ddd;
    }
}

/* ==========================================
   Skeleton Loading
   ========================================== */

.onestop-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: onestop-shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes onestop-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.onestop-skeleton-item {
    pointer-events: none;
}

.onestop-skeleton-text {
    display: inline-block;
    width: 80px;
    height: 14px;
}

.onestop-skeleton-small {
    display: inline-block;
    width: 40px;
    height: 12px;
}

.onestop-skeleton-image {
    width: 100%;
    height: 100%;
}

.onestop-skeleton-title {
    width: 80%;
    height: 16px;
    margin-bottom: 8px;
}

.onestop-skeleton-meta {
    width: 50%;
    height: 12px;
    margin-bottom: 8px;
}

.onestop-skeleton-price {
    width: 30%;
    height: 14px;
}

/* Dark mode skeleton */
@media (prefers-color-scheme: dark) {
    .onestop-skeleton {
        background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
        background-size: 200% 100%;
    }
}

/* ==========================================
   Error & Retry
   ========================================== */

.onestop-search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    text-align: center;
    color: #d32f2f;
}

.onestop-retry-btn {
    padding: 8px 16px;
    font-size: 13px;
    color: #0066cc;
    background: #fff;
    border: 1px solid #0066cc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.onestop-retry-btn:hover {
    background: #0066cc;
    color: #fff;
}

/* Dark mode error */
@media (prefers-color-scheme: dark) {
    .onestop-search-error {
        color: #ef5350;
    }

    .onestop-retry-btn {
        background: #1a1a1a;
        border-color: #4da6ff;
        color: #4da6ff;
    }

    .onestop-retry-btn:hover {
        background: #4da6ff;
        color: #1a1a1a;
    }
}

/* ==========================================
   Did You Mean
   ========================================== */

.onestop-did-you-mean {
    padding: 10px 16px;
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    font-size: 13px;
    color: #856404;
}

.onestop-did-you-mean-link {
    color: #0066cc;
    font-weight: 600;
    text-decoration: none;
    margin-left: 4px;
}

.onestop-did-you-mean-link:hover {
    text-decoration: underline;
}

/* Dark mode did you mean */
@media (prefers-color-scheme: dark) {
    .onestop-did-you-mean {
        background: #3a3000;
        border-color: #665200;
        color: #ffc107;
    }

    .onestop-did-you-mean-link {
        color: #4da6ff;
    }
}
