/**
 * Estilos para el Sistema de Búsqueda Universal
 * Vive Aguachica - Solo estilos para resultados, respeta estilos originales del header
 */

/* ===== AJUSTES MÍNIMOS AL CONTENEDOR EXISTENTE ===== */
.search-container {
    position: relative;
    /* Mantener z-index original pero asegurar que los resultados aparezcan encima */
}

/* NO sobrescribir .search-box, .search-icon, #searchInput - usar estilos originales */
/* NO modificar .header - mantener estilos originales */
/* NO modificar .main-content - mantener margin-top: 80px original */

/* ===== BOTÓN DE BÚSQUEDA POR VOZ ===== */
.search-box {
    position: relative;
}

/* Ajustar el input para hacer espacio al botón de voz */
.search-box #searchInput {
    padding-right: 45px !important;
}

.voice-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #666;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    z-index: 15;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.voice-search-btn:hover {
    background: rgba(74, 144, 226, 0.1);
    color: #4a90e2;
}

.voice-search-btn.listening {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
    }
}

/* ===== CONTENEDOR DE RESULTADOS ===== */
.search-results {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1050; /* Mayor que el header (1000) */
    backdrop-filter: blur(20px);
    animation: searchResultsSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes searchResultsSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== ESTADÍSTICAS DE BÚSQUEDA ===== */
.search-stats {
    padding: 12px 16px;
    font-size: 12px;
    color: #666;
    background: rgba(74, 144, 226, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 500;
}

/* ===== GRUPOS DE RESULTADOS ===== */
.search-group {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.search-group-header {
    display: flex;
    align-items: center;
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #4a90e2;
    background: rgba(74, 144, 226, 0.03);
    border-bottom: 1px solid rgba(74, 144, 226, 0.1);
}

.search-group-header i {
    margin-right: 8px;
    font-size: 14px;
}

/* ===== ELEMENTOS DE RESULTADO ===== */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.search-result-item:hover,
.search-result-item.highlighted {
    background: rgba(74, 144, 226, 0.08);
    border-left-color: #4a90e2;
}

.search-result-item:active {
    background: rgba(74, 144, 226, 0.12);
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 8px;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.result-icon i {
    color: white;
    font-size: 18px;
}

/* Estilos específicos para imágenes de portada */
.result-icon.result-image {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.result-icon.result-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 7px;
    transition: transform 0.2s ease;
    z-index: 1;
}

.result-icon.result-image img:hover {
    transform: scale(1.02);
}

/* Asegurar que no haya contenido de fondo visible */
.result-icon.result-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    z-index: 0;
}

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

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    line-height: 1.3;
}

.result-title mark {
    background: rgba(255, 235, 59, 0.6);
    color: #333;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 700;
}

.result-info {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    margin-bottom: 2px;
}

.result-match {
    font-size: 11px;
    color: #888;
    font-style: italic;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-type {
    font-size: 11px;
    color: #4a90e2;
    font-weight: 600;
    background: rgba(74, 144, 226, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ===== ESTADOS ESPECIALES ===== */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #666;
}

.search-loading .loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(74, 144, 226, 0.2);
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-no-results,
.search-error {
    padding: 24px;
    text-align: center;
    color: #666;
}

.no-results-icon,
.error-icon {
    font-size: 32px;
    color: #ccc;
    margin-bottom: 12px;
}

.error-icon {
    color: #ff6b6b;
}

.no-results-text h4,
.error-text h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.no-results-text p,
.error-text p {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.4;
}

.search-suggestions {
    text-align: left;
    background: rgba(74, 144, 226, 0.05);
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.search-suggestions p {
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 13px;
    color: #4a90e2;
}

.search-suggestions ul {
    margin: 0;
    padding-left: 16px;
    list-style-type: disc;
}

.search-suggestions li {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.3;
}

/* ===== RESPONSIVE SOLO PARA RESULTADOS ===== */
@media (max-width: 768px) {
    /* NO modificar .search-box - mantener estilos originales */
    
    .search-results {
        max-height: 400px;
    }
    
    .result-content {
        margin-right: 8px;
    }
    
    .result-type {
        display: none;
    }
}

@media (max-width: 480px) {
    /* NO modificar .search-box - mantener estilos originales */
    
    .search-results {
        left: -20px;
        right: -20px;
        max-height: 350px;
    }
    
    .search-result-item {
        padding: 10px 12px;
    }
    
    .result-icon {
        width: 32px;
        height: 32px;
        margin-right: 10px;
    }
    
    .result-icon i {
        font-size: 14px;
    }
    
    .result-title {
        font-size: 13px;
    }
    
    .result-info {
        font-size: 11px;
    }
    
    .result-match {
        display: none;
    }
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 226, 0.3);
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 144, 226, 0.5);
}

/* ===== ANIMACIONES ADICIONALES ===== */
.search-result-item {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

.search-result-item:nth-child(1) { animation-delay: 0.05s; }
.search-result-item:nth-child(2) { animation-delay: 0.1s; }
.search-result-item:nth-child(3) { animation-delay: 0.15s; }
.search-result-item:nth-child(4) { animation-delay: 0.2s; }
.search-result-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== TEMA OSCURO SOLO PARA RESULTADOS ===== */
@media (prefers-color-scheme: dark) {
    /* NO modificar .search-box, #searchInput - mantener estilos originales */
    
    .search-results {
        background: rgba(30, 30, 30, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .result-title {
        color: #fff;
    }
    
    .result-info {
        color: #ccc;
    }
    
    .result-match {
        color: #aaa;
    }
    
    .search-stats {
        color: #ccc;
        background: rgba(74, 144, 226, 0.1);
    }
    
    .search-group-header {
        color: #4a90e2;
        background: rgba(74, 144, 226, 0.05);
    }
    
    .no-results-text h4,
    .error-text h4 {
        color: #fff;
    }
}
