/* search-styles.css - Estilos para o sistema de busca melhorado */

/* Animações de busca */
@keyframes searchPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

@keyframes searchSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes searchFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Barra de busca melhorada */
#search-bar {
    transition: all 0.3s ease;
    position: relative;
}

#search-bar:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#search-bar.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M21 12a9 9 0 11-6.219-8.56'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px 20px;
    animation: searchPulse 1.5s ease-in-out infinite;
}

/* Container de sugestões */
#search-suggestions {
    animation: searchSlideIn 0.2s ease-out;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

#search-suggestions.hidden {
    animation: searchFadeIn 0.15s ease-out reverse;
}

/* Itens de sugestão */
.suggestion-item {
    transition: all 0.2s ease;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.suggestion-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.1), transparent);
    transition: left 0.5s ease;
}

.suggestion-item:hover::before {
    left: 100%;
}

.suggestion-item:hover {
    background-color: rgba(139, 92, 246, 0.1);
    transform: translateX(4px);
}

.suggestion-item.selected {
    background-color: rgba(139, 92, 246, 0.2);
    border-left: 3px solid #8B5CF6;
}

/* Estatísticas de busca */
#search-stats {
    animation: searchSlideIn 0.3s ease-out;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
}

#search-stats .text-brand-purple {
    background: linear-gradient(135deg, #8B5CF6, #EC4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mensagem de "nenhum resultado" */
#search-no-results {
    animation: searchSlideIn 0.4s ease-out;
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.1), rgba(75, 85, 99, 0.1));
    border: 1px solid rgba(107, 114, 128, 0.2);
}

#search-no-results svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Cards de resultados com animação */
.search-result-card {
    animation: searchFadeIn 0.3s ease-out;
    transition: all 0.3s ease;
}

.search-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Indicador de busca ativa */
.search-active-indicator {
    position: relative;
}

.search-active-indicator::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #8B5CF6, #EC4899);
    border-radius: 1px;
    animation: searchPulse 2s ease-in-out infinite;
}

/* Botão de limpar busca */
.clear-search-btn {
    transition: all 0.2s ease;
    opacity: 0.7;
}

.clear-search-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Responsividade para mobile */
@media (max-width: 768px) {
    #search-suggestions {
        margin-top: 8px;
        border-radius: 12px;
    }
    
    .suggestion-item {
        padding: 12px 16px;
        font-size: 16px; /* Previne zoom no iOS */
    }
    
    #search-stats, #search-no-results {
        margin: 16px;
        padding: 16px;
    }
}

/* Melhorias de acessibilidade */
.suggestion-item:focus {
    outline: 2px solid #8B5CF6;
    outline-offset: 2px;
}

#search-bar:focus {
    outline: none;
}

/* Loading spinner customizado */
.search-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    border-top-color: #8B5CF6;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Destaque de texto pesquisado */
.search-highlight {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(236, 72, 153, 0.3));
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* Tooltip para sugestões */
.suggestion-item[title] {
    position: relative;
}

.suggestion-item[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 4px;
}

/* Animações de entrada para resultados */
.search-results-enter {
    animation: searchSlideIn 0.3s ease-out;
}

.search-results-enter:nth-child(1) { animation-delay: 0.05s; }
.search-results-enter:nth-child(2) { animation-delay: 0.1s; }
.search-results-enter:nth-child(3) { animation-delay: 0.15s; }
.search-results-enter:nth-child(4) { animation-delay: 0.2s; }
.search-results-enter:nth-child(5) { animation-delay: 0.25s; }

/* Melhorias para modo escuro */
@media (prefers-color-scheme: dark) {
    #search-suggestions {
        background: rgba(15, 15, 15, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    #search-stats {
        background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.15));
    }
}

/* Estados de erro */
.search-error {
    border-color: #EF4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.search-error-message {
    color: #EF4444;
    font-size: 14px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Melhorias de performance */
.search-container {
    contain: layout style paint;
}

.suggestion-item {
    contain: layout style;
}

/* Animações reduzidas para usuários que preferem menos movimento */
@media (prefers-reduced-motion: reduce) {
    #search-suggestions,
    .suggestion-item,
    #search-stats,
    #search-no-results,
    .search-result-card {
        animation: none;
        transition: none;
    }
    
    .suggestion-item:hover {
        transform: none;
    }
    
    #search-bar:focus {
        transform: none;
    }
}
