/* Smart Product Search Styles for Ghorbari eCommerce */

/* Search Container */
.smart-search-container {
    position: relative;
    width: 100%;
}

/* Search Input - Clean white design with black text */
.smart-search-input {
    width: 100%;
    padding: 12px 50px 12px 16px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    background-color: #ffffff !important;
    color: #000000 !important;
    transition: all 0.3s ease;
    outline: none;
    border-radius: 8px;
}

.smart-search-input:focus {
    border-color: #5a3e2b;
    box-shadow: 0 0 0 2px rgba(90, 62, 43, 0.1);
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Header search inputs - white background with black text */
#desktop-search-form .smart-search-input,
#mobile-search-form .smart-search-input,
#sticky-search-form .smart-search-input {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 8px 48px 8px 16px;
}

#desktop-search-form .smart-search-input:focus,
#mobile-search-form .smart-search-input:focus,
#sticky-search-form .smart-search-input:focus {
    border-color: #5a3e2b;
    box-shadow: 0 0 0 2px rgba(90, 62, 43, 0.1);
    background-color: #ffffff !important;
    color: #000000 !important;
}

.smart-search-input::placeholder {
    color: #9ca3af !important;
    font-weight: 400;
}

/* Ensure text is always black in search inputs */
.smart-search-input,
input[name="search"] {
    color: #000000 !important;
    background-color: #ffffff !important;
}

.smart-search-input:focus,
input[name="search"]:focus {
    color: #000000 !important;
    background-color: #ffffff !important;
}

/* Search Icon - Clean design with no background */
.smart-search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 18px;
    pointer-events: none;
    z-index: 2;
}

.search-focused .smart-search-icon {
    color: #5a3e2b;
}

/* Header search buttons - clean icon style */
#desktop-search-form button[type="submit"],
#mobile-search-form button[type="submit"],
#sticky-search-form button[type="submit"] {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 8px;
    border-radius: 4px;
}

#desktop-search-form button[type="submit"]:hover,
#mobile-search-form button[type="submit"]:hover,
#sticky-search-form button[type="submit"]:hover {
    color: #5a3e2b;
    background: none;
}

#desktop-search-form button[type="submit"]:focus,
#mobile-search-form button[type="submit"]:focus,
#sticky-search-form button[type="submit"]:focus {
    outline: none;
    color: #5a3e2b;
}

/* Standalone search input (for demo and other pages) */
#smart-search-container .smart-search-container {
    max-width: 600px;
    margin: 0 auto;
}

.smart-search-input:not(#smart-search-input-desktop):not(#smart-search-input-mobile):not(#smart-search-input-sticky) {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 12px 50px 12px 16px;
    background-color: #ffffff;
    color: #000000;
}

.smart-search-input:not(#smart-search-input-desktop):not(#smart-search-input-mobile):not(#smart-search-input-sticky):focus {
    border-color: #5a3e2b;
    box-shadow: 0 0 0 3px rgba(90, 62, 43, 0.1);
    background-color: #ffffff;
    color: #000000;
}

/* Typeahead Dropdown */
.smart-search-dropdown,
.tt-menu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    z-index: 1000 !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    margin-top: -1px !important;
    animation: slideDown 0.2s ease-out;
    display: block !important;
}

/* Ensure dropdown is visible when open */
.tt-menu.tt-open {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* For header search dropdowns */
#desktop-search-form .tt-menu,
#mobile-search-form .tt-menu,
#sticky-search-form .tt-menu {
    border-radius: 0 0 6px 6px !important;
    border: 1px solid #d1d5db !important;
    border-top: none !important;
    background: #ffffff !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Individual Suggestion */
.smart-search-suggestion,
.tt-suggestion {
    padding: 0 !important;
    border-bottom: 1px solid #f3f4f6 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
    display: block !important;
    background: #ffffff !important;
}

.smart-search-suggestion:last-child,
.tt-suggestion:last-child {
    border-bottom: none !important;
}

.smart-search-suggestion:hover,
.smart-search-cursor,
.tt-suggestion:hover,
.tt-cursor {
    background-color: #f9fafb !important;
}

.smart-suggestion {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

/* Suggestion Image */
.suggestion-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f3f4f6;
}

.suggestion-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.smart-search-suggestion:hover .suggestion-image img {
    transform: scale(1.05);
}

/* Suggestion Content */
.suggestion-content {
    flex: 1;
    min-width: 0;
}

.suggestion-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-category {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: capitalize;
}

.suggestion-pricing {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.suggestion-price {
    font-weight: 700;
    color: #1f2937;
    font-size: 14px;
}

.suggestion-price-discounted {
    font-weight: 700;
    color: #000000;
    font-size: 14px;
}

.suggestion-price-original {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: line-through;
}

/* Suggestion Arrow */
.suggestion-arrow {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
}

.smart-search-suggestion:hover .suggestion-arrow {
    opacity: 1;
    color: #5a3e2b;
    transform: translateX(2px);
}

/* Search Highlight */
.search-highlight {
    background-color: #fef3c7;
    color: #92400e;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Empty State */
.smart-search-empty {
    padding: 20px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.smart-search-empty::before {
    content: "🔍";
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
}

/* Loading State */
.smart-search-loading {
    padding: 20px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.smart-search-loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #5a3e2b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .smart-search-container {
        max-width: 100%;
    }
    
    .smart-search-input {
        padding: 14px 50px 14px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .smart-search-dropdown {
        max-height: 300px;
        border-radius: 0 0 12px 12px;
    }
    
    .smart-suggestion {
        padding: 14px 16px;
        gap: 14px;
    }
    
    .suggestion-image {
        width: 45px;
        height: 45px;
    }
    
    .suggestion-name {
        font-size: 15px;
    }
    
    .suggestion-category {
        font-size: 13px;
    }
    
    .suggestion-price,
    .suggestion-price-discounted {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .smart-search-input {
        padding: 12px 45px 12px 14px;
    }
    
    .smart-search-icon {
        right: 14px;
        font-size: 16px;
    }
    
    .smart-suggestion {
        padding: 12px 14px;
        gap: 12px;
    }
    
    .suggestion-image {
        width: 40px;
        height: 40px;
    }
    
    .suggestion-name {
        font-size: 14px;
    }
    
    .suggestion-category {
        font-size: 12px;
    }
    
    .suggestion-pricing {
        gap: 6px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .smart-search-input {
        background-color: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .smart-search-input::placeholder {
        color: #9ca3af;
    }
    
    .smart-search-dropdown {
        background-color: #1f2937;
        border-color: #374151;
    }
    
    .smart-search-suggestion:hover,
    .smart-search-cursor {
        background-color: #374151;
    }
    
    .suggestion-name {
        color: #f9fafb;
    }
    
    .suggestion-price {
        color: #f9fafb;
    }
    
    .suggestion-price-discounted {
        color: #ffffff;
    }
    
    .smart-search-empty {
        color: #9ca3af;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .smart-search-input {
        border-width: 3px;
    }
    
    .search-highlight {
        background-color: #ffff00;
        color: #000000;
        font-weight: 700;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .smart-search-dropdown {
        animation: none;
    }
    
    .suggestion-image img,
    .suggestion-arrow {
        transition: none;
    }
    
    .smart-search-loading::before {
        animation: none;
    }
}

/* Focus Visible for Accessibility */
.smart-search-suggestion:focus-visible {
    outline: 2px solid #5a3e2b;
    outline-offset: -2px;
}

/* Print Styles */
@media print {
    .smart-search-container {
        display: none;
    }
}