/**
 * Multitrade Instant Search Styles
 *
 * @package Multitrade
 * @since 1.1.0
 */

/* Search wrapper */
.mt-instant-search {
    position: relative;
    width: 100%;
}

.mt-instant-search input[type="search"],
.mt-instant-search input[type="text"],
input.mt-search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 44px;
    font-size: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 14px center no-repeat;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mt-instant-search input:focus {
    outline: none;
    border-color: var(--mt-primary, #E31E24);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.1);
}

/* Dropdown container */
.mt-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
    z-index: 9999;
    max-height: 480px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.mt-search-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Section styling */
.mt-search-section {
    padding: 8px 0;
}

.mt-search-section + .mt-search-section {
    border-top: 1px solid #f3f4f6;
}

.mt-search-section-header {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}

/* Search items */
.mt-search-item {
    transition: background-color 0.15s;
}

.mt-search-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
}

.mt-search-item:hover,
.mt-search-item.is-selected {
    background-color: #f9fafb;
}

.mt-search-item.is-selected {
    background-color: #f3f4f6;
}

/* Item image */
.mt-search-item-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.mt-search-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Category items have smaller images */
.mt-search-item-category .mt-search-item-image {
    width: 40px;
    height: 40px;
    border-radius: 6px;
}

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

.mt-search-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mt-search-item-sku {
    font-size: 12px;
    color: #6b7280;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.mt-search-item-meta {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* View all link */
.mt-search-view-all {
    padding: 12px 16px;
    border-top: 1px solid #f3f4f6;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.mt-search-view-all a {
    display: block;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--mt-primary, #E31E24);
    text-decoration: none;
    transition: color 0.15s;
}

.mt-search-view-all a:hover {
    color: var(--mt-primary-dark, #c41a1f);
    text-decoration: underline;
}

/* Loading state */
.mt-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.mt-search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--mt-primary, #E31E24);
    border-radius: 50%;
    animation: mt-spin 0.8s linear infinite;
}

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

/* No results */
.mt-search-no-results {
    padding: 32px 24px;
    text-align: center;
}

.mt-search-no-results p {
    margin: 0;
    font-size: 14px;
    color: #374151;
}

.mt-search-suggestion {
    margin-top: 8px !important;
    font-size: 13px !important;
    color: #9ca3af !important;
}

/* Error state */
.mt-search-error {
    padding: 24px;
    text-align: center;
    color: #dc2626;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 640px) {
    .mt-search-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
    }

    .mt-search-item a {
        padding: 12px 16px;
    }

    .mt-search-item-image {
        width: 56px;
        height: 56px;
    }

    .mt-search-item-name {
        font-size: 15px;
    }
}

/* Header search specific styling */
.site-header .mt-instant-search,
header .mt-instant-search {
    max-width: 400px;
}

/* Dark background variant */
.mt-instant-search--dark input[type="search"],
.mt-instant-search--dark input[type="text"] {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.mt-instant-search--dark input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}
