/**
 * Estilos de Búsqueda
 * Sistema de búsqueda en tiempo real con autocompletado
 */

/* ============================================
   BARRA DE BÚSQUEDA GLOBAL (DEBAJO DEL HEADER)
   ============================================ */

.search-banner {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem 0;
    position: relative;
    z-index: 50;
}

.search-banner-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-input-group {
    position: relative;
    width: 100%;
}

.search-input-group .search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #718096;
    pointer-events: none;
    z-index: 1;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem 1rem 3.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 3rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-input:focus {
    outline: none;
    border-color: #008c2b;
    background: white;
    box-shadow: 0 4px 16px rgba(72, 187, 120, 0.15);
    transform: translateY(-1px);
}

/* ============================================
   RESULTADOS DE BÚSQUEDA (DROPDOWN)
   ============================================ */

.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.search-results.active {
    max-height: 500px;
    opacity: 1;
    overflow-y: auto;
}

.search-results-list {
    padding: 0.5rem;
}

/* ============================================
   ITEMS DE RESULTADOS
   ============================================ */

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.search-result-item:hover,
.search-result-item.active {
    background: #f7fafc;
    transform: translateX(4px);
}

.search-result-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f7fafc;
}

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

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-name mark {
    background: #c6f6d5;
    color: #22543d;
    padding: 0 0.2rem;
    border-radius: 0.2rem;
}

.search-result-category {
    font-size: 0.75rem;
    color: #718096;
}

.search-result-price {
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #008c2b;
}

/* ============================================
   FOOTER DE RESULTADOS
   ============================================ */

.search-results-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
}

.search-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 0.5rem;
    color: #008c2b;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.search-view-all:hover {
    background: #008c2b;
    color: white;
    transform: translateY(-1px);
}

/* ============================================
   ESTADOS ESPECIALES
   ============================================ */

/* Sin resultados */
.search-no-results {
    padding: 2rem;
    text-align: center;
    color: #718096;
}

.search-no-results svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-no-results p {
    margin-bottom: 1rem;
}

.search-try-advanced {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #008c2b;
    color: white;
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.search-try-advanced:hover {
    background: #38a169;
    transform: translateY(-1px);
}

/* Loading */
.search-loading {
    padding: 2rem;
    text-align: center;
    color: #718096;
}

.search-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid #e2e8f0;
    border-top-color: #008c2b;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#searchBar {
    z-index: 9999;
}
/* Error */
.search-error {
    padding: 2rem;
    text-align: center;
    color: #e53e3e;
}

.search-error svg {
    margin-bottom: 1rem;
}

/* ============================================
   OVERLAY
   ============================================ */

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 99;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    .search-banner {
        padding: 1rem 0;
    }
    
    .search-banner-content {
        padding: 0 1rem;
    }
    
    .search-input {
        font-size: 1rem;
        padding: 0.875rem 1.25rem 0.875rem 3rem;
    }
    
    .search-input-group .search-icon {
        left: 1rem;
    }
    
    .search-results {
        max-height: calc(100vh - 200px);
    }
    
    .search-result-item {
        padding: 1rem 0.5rem;
    }
    
    .search-result-name {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .search-banner {
        padding: 0.75rem 0;
    }
    
    .search-input {
        padding: 0.75rem 1rem 0.75rem 2.75rem;
        font-size: 0.95rem;
    }
    
    .search-result-image {
        width: 40px;
        height: 40px;
    }
    
    .search-result-price {
        font-size: 0.9rem;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

.search-input:focus-visible {
    outline: 2px solid #008c2b;
    outline-offset: 2px;
}

.search-result-item:focus-visible {
    outline: 2px solid #008c2b;
    outline-offset: -2px;
}

/* Reducir movimiento para usuarios con preferencias */
@media (prefers-reduced-motion: reduce) {
    .search-results,
    .search-overlay,
    .search-result-item,
    .search-view-all,
    .search-try-advanced {
        transition: none;
    }
    
    .search-spinner {
        animation: none;
        border-top-color: #e2e8f0;
    }
}