/**
 * Smart Search Styles
 */

/* Container */
.smart-search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Input wrapper */
.smart-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Input field */
.smart-search-input {
    width: 100%;
    padding: 12px 45px 12px 16px;
    font-size: 14px;
    font-weight: 400;
    color: #333;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.smart-search-input:focus {
    border-color: #e51c20;
    box-shadow: 0 0 0 3px rgba(229, 28, 32, 0.1);
}

.smart-search-input::placeholder {
    color: #9ca3af;
}

/* Search icon */
.smart-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loader */
.smart-search-loader {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #e51c20;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: smart-search-spin 1s linear infinite;
}

@keyframes smart-search-spin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Results dropdown */
.smart-search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 450px;
    overflow-y: auto;
    z-index: 9999;
}

/* Scrollbar styling */
.smart-search-results::-webkit-scrollbar {
    width: 6px;
}

.smart-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.smart-search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.smart-search-results::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Single result item */
.smart-search-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
}

.smart-search-item:last-child {
    border-bottom: none;
}

.smart-search-item:hover,
.smart-search-item.active {
    background-color: #f9fafb;
}

/* Product image */
.smart-search-item-image {
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 8px;
    object-fit: cover;
    background-color: #f3f4f6;
    margin-right: 12px;
}

/* Product info */
.smart-search-item-info {
    flex: 1;
    min-width: 0;
}

.smart-search-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.smart-search-item-sku {
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
}

/* Product price */
.smart-search-item-price {
    font-size: 14px;
    font-weight: 600;
    color: #e51c20;
    white-space: nowrap;
    margin-left: 12px;
}

.smart-search-item-price del {
    color: #9ca3af;
    font-weight: 400;
    font-size: 12px;
}

.smart-search-item-price ins {
    text-decoration: none;
}

/* No results message */
.smart-search-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #6b7280;
}

.smart-search-no-results-icon {
    font-size: 40px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.smart-search-no-results-text {
    font-size: 14px;
    margin: 0;
}

.smart-search-no-results-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 5px;
}

/* View all results link */
.smart-search-view-all {
    display: block;
    padding: 14px 16px;
    text-align: center;
    color: #e51c20;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-top: 1px solid #e2e8f0;
    background: #fafafa;
    border-radius: 0 0 10px 10px;
    transition: background-color 0.15s ease;
}

.smart-search-view-all:hover {
    background-color: #f3f4f6;
    color: #c41518;
}

/* Loading state */
.smart-search-loading {
    padding: 30px 20px;
    text-align: center;
    color: #6b7280;
}

/* Highlight matched text */
.smart-search-highlight {
    background-color: #fef3c7;
    padding: 0 2px;
    border-radius: 2px;
}

/* Mobile responsive */
@media (max-width: 550px) {
    .smart-search-container {
        max-width: 100%;
    }

    .smart-search-input {
        padding: 10px 40px 10px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .smart-search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        border: none;
        box-shadow: 0 -5px 40px rgba(0, 0, 0, 0.2);
    }

    .smart-search-item {
        padding: 14px 16px;
    }

    .smart-search-item-image {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }

    .smart-search-item-title {
        font-size: 13px;
    }

    .smart-search-item-price {
        font-size: 13px;
    }
}

/* Dark overlay for mobile */
.smart-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.smart-search-overlay.active {
    display: block;
}

/* Category badge */
.smart-search-item-category {
    font-size: 10px;
    color: #fff;
    background: #6b7280;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    white-space: nowrap;
}

/* Keyboard navigation hint */
.smart-search-hint {
    padding: 8px 16px;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #f3f4f6;
    background: #fafafa;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.smart-search-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-family: monospace;
    background: #e5e7eb;
    border-radius: 4px;
    margin-right: 4px;
}

/* Animation */
@keyframes smart-search-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.smart-search-results {
    animation: smart-search-fade-in 0.2s ease;
}
