/* Estilos principales del buscador */
.elastic-product-search-widget {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Campo de búsqueda */
.search-input-container {
    position: relative;
    margin-bottom: 10px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    background: #fff;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1), 0 4px 12px rgba(0,0,0,0.1);
}

.search-input::placeholder {
    color: #8e9aaf;
    font-style: italic;
}

/* Iconos en el campo de búsqueda */
.search-icon {
    position: absolute;
    right: 16px;
    color: #8e9aaf;
    pointer-events: none;
    transition: color 0.2s ease;
}

.search-input:focus + .search-icon {
    color: #0073aa;
}

.search-loading {
    position: absolute;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-clear {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: #8e9aaf;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.search-clear:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Contenedor de resultados */
.search-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    border: 1px solid #e1e5e9;
    z-index: 1000;
    max-height: 500px;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header de resultados */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    color: #6c757d;
}

.close-results {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-results:hover {
    background: #e9ecef;
    color: #495057;
}

/* Lista de resultados */
.search-results-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.search-result-item {
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
    background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 100%);
}

.result-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.result-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: row;
    padding: 10px 20px;
}
.result-content img{
    margin-right: 10px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.result-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    line-height: 1.3;
    flex: 1;
    text-align: left;
}

.result-title mark {
    background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
    color: #2d3748;
}

.result-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #718096;
    white-space: nowrap;
}

.result-ref {
    background: #e6fffa;
    color: #234e52;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.result-ean {
    background: #fef5e7;
    color: #744210;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.result-score {
    color: #a0aec0;
    font-style: italic;
}

.result-description {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.4;
    overflow: hidden;
    text-align: left;
}

.result-description img{
    height: 30px;
}

.result-description mark {
    background: linear-gradient(120deg, #fed7d7 0%, #fbb6ce 100%);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

.result-arrow {
    margin-left: 12px;
    color: #a0aec0;
    transition: all 0.2s ease;
}

.search-result-item:hover .result-arrow,
.search-result-item.active .result-arrow {
    color: #0073aa;
    transform: translateX(4px);
}

/* Sin resultados */
.search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.no-results-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-no-results h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #4a5568;
}

.search-no-results p {
    margin: 0;
    font-size: 14px;
}

/* Sugerencias */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid #e1e5e9;
    z-index: 999;
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.suggestions-title {
    font-size: 14px;
    color: #718096;
    margin-bottom: 12px;
    font-weight: 500;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-item {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 14px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-item:hover {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

/* Errores */
.search-error {
    display: flex;
    align-items: center;
    padding: 20px;
    color: #e53e3e;
    background: #fed7d7;
    margin: 10px;
    border-radius: 8px;
    gap: 12px;
}

.error-icon {
    font-size: 20px;
}

.error-message {
    font-size: 14px;
}

/* Variantes de estilo */
.search-style-compact .search-input-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.search-style-compact .search-results-container {
    max-width: 400px;
    margin: 0 auto;
}

.search-style-full {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 16px;
    margin: 20px 0;
}

.search-style-full .search-input-wrapper {
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.search-style-full .search-input {
    font-size: 18px;
    padding: 18px 60px 18px 24px;
    border: none;
}

/* Responsive */
@media (max-width: 768px) {
    .elastic-product-search-widget {
        max-width: 100%;
        margin: 0;
    }

    .search-input {
        font-size: 16px; /* Evita zoom en iOS */
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .result-meta {
        flex-direction: column;
        gap: 4px;
    }

    .suggestions-list {
        justify-content: center;
    }

    .search-style-full {
        padding: 20px;
        margin: 10px 0;
    }
}

/* Scrollbar personalizada */
.search-results-list::-webkit-scrollbar {
    width: 6px;
}

.search-results-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-results-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Estados de focus para accesibilidad */
.search-result-item:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

.suggestion-item:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Animaciones adicionales */
.search-result-item {
    animation: slideInUp 0.1s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enlace "Mostrar todos" al final de resultados */
.search-show-all {
    border-top: 2px solid #e9ecef;
    margin-top: 8px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transition: all 0.2s ease;
    animation: slideInUp 0.1s ease-out;
}

.search-show-all:hover,
.search-show-all.show-all-active {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.show-all-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
}

.show-all-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
}

.show-all-icon {
    color: #0073aa;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    transition: color 0.2s ease;
}

.show-all-text {
    flex: 1;
    min-width: 0;
}

.show-all-text strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
    line-height: 1.3;
}

.show-all-count {
    display: block;
    font-size: 13px;
    color: #718096;
    font-style: italic;
    line-height: 1.2;
}

.show-all-arrow {
    color: #0073aa;
    transition: all 0.2s ease;
    margin-left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-show-all:hover .show-all-arrow,
.search-show-all.show-all-active .show-all-arrow {
    color: #005a87;
    transform: translateX(4px);
}

.search-show-all:hover .show-all-icon,
.search-show-all.show-all-active .show-all-icon {
    color: #005a87;
}

/* Estados de focus para accesibilidad */
.search-show-all:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* Responsive para el enlace "mostrar todos" */
@media (max-width: 768px) {
    .show-all-content {
        padding: 14px 16px;
        gap: 10px;
    }

    .show-all-text strong {
        font-size: 15px;
    }

    .show-all-count {
        font-size: 12px;
    }

    .show-all-icon {
        min-width: 18px;
    }

    .show-all-arrow {
        margin-left: 8px;
    }
}