/**
 * Estilos para el buscador en tiempo real
 * Inspirado en el diseño de Apple
 */

/* Formulario de búsqueda */
.search-form {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s cubic-bezier(0.3, 0, 0.2, 1);
    z-index: 1000;
    border: 1px solid rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    overflow: hidden;
}

.search-form.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(12px);
}

/* Contenedor del input */
.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 12px;
}

/* Ícono de búsqueda */
.search-icon {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #86868b;
    font-size: 16px;
    z-index: 2;
    pointer-events: none;
}

/* Input de búsqueda */
.search-input {
    width: 100%;
    padding: 10px 40px 10px 34px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.05);
    color: #1d1d1f;
    font-weight: 400;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    background-color: rgba(0, 0, 0, 0.08);
}

/* Botón para limpiar input */
.search-clear-button {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #86868b;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.search-clear-button:hover {
    opacity: 1;
}

/* Resultados de búsqueda */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Estilo cuando está cargando */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #86868b;
}

.search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-primary, #ff5a1f);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

/* Mensaje de error */
.search-error {
    padding: 20px;
    text-align: center;
    color: #f44336;
}

.search-error small {
    display: block;
    color: #86868b;
    font-size: 12px;
    margin-top: 4px;
}

/* Mensaje de sin resultados */
.search-no-results {
    padding: 24px;
    text-align: center;
    color: #1d1d1f;
}

.search-no-results i {
    font-size: 32px;
    color: #d2d2d7;
    margin-bottom: 12px;
}

.search-no-results p {
    margin-bottom: 12px;
    font-weight: 500;
}

.search-no-results a {
    color: var(--color-primary, #ff5a1f);
    font-size: 13px;
    text-decoration: none;
}

.search-no-results a:hover {
    text-decoration: underline;
}

/* Contenido de resultados */
.search-content {
    padding: 8px 0;
}

/* Títulos de sección */
.search-content h3 {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Sección de categorías */
.search-categories {
    margin-bottom: 12px;
}

.search-categories-list {
    display: flex;
    flex-wrap: wrap;
    padding: 0 12px;
    gap: 6px;
}

.search-category-item {
    font-size: 12px;
    color: #1d1d1f;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 4px 10px;
    border-radius: 100px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.search-category-item:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

/* Lista de productos */
.search-products-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Elemento de producto */
.search-product-item {
    display: flex;
    padding: 10px 16px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    border-radius: 8px;
    margin: 0 6px;
}

.search-product-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Imagen del producto */
.search-product-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    margin-right: 12px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f5f5f7;
}

.search-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-product-item:hover .search-product-image img {
    transform: scale(1.05);
}

.search-product-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d2d2d7;
    font-size: 20px;
}

/* Información del producto */
.search-product-info {
    flex: 1;
    min-width: 0;
}

.search-product-name {
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-product-category {
    font-size: 11px;
    color: var(--color-primary, #ff5a1f);
    margin-bottom: 4px;
}

.search-product-price {
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
}

.search-product-old-price {
    font-size: 11px;
    color: #86868b;
    text-decoration: line-through;
    margin-left: 5px;
    font-weight: normal;
}

/* Resaltar coincidencias */
.search-product-name mark {
    background-color: rgba(255, 90, 31, 0.15);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* Ver todos los resultados */
.search-view-all {
    padding: 12px 16px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.search-view-all a {
    color: var(--color-primary, #ff5a1f);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.search-view-all a:hover {
    text-decoration: underline;
}

.search-view-all a i {
    margin-left: 4px;
}

/* Búsquedas populares */
.search-popular {
    padding: 8px 0;
}

.search-popular-list {
    padding: 0 12px;
}

.search-popular-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #1d1d1f;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.search-popular-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.search-popular-item i {
    color: #86868b;
    margin-right: 8px;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 767px) {
    .search-form {
        width: 280px;
    }
}

@media (max-width: 479px) {
    .search-form {
        width: 250px;
        right: -10px;
    }
    
    .search-product-item {
        padding: 8px 12px;
    }
    
    .search-product-image {
        width: 40px;
        height: 40px;
        margin-right: 10px;
    }
}