/**
 * Estilos para el módulo de búsqueda desplegable
 * modules/dropdownsearch/views/css/dropdownsearch.css
 */

/* Overlay principal */
body:has(.dropdown-search-overlay.active),
html:has(.dropdown-search-overlay.active) {
    overflow: hidden !important;
}
.dropdown-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    display: flex !important; /* Forzar display flex para sobrescribir inline style */
    transition: all 0.3s ease;
}

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

/* Contenedor de búsqueda */
.dropdown-search-container {
    position: relative;
    width: 100%;
    margin: 0;
    background: #ffffff;
    border-radius: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.dropdown-search-overlay.active .dropdown-search-container {
    transform: translateY(0);
}

/* Wrapper del input de búsqueda */
.search-input-wrapper {
    position: relative;
    padding: 30px 50px 30px 30px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    max-width: 900px;
    float:none;
    margin-inline:auto;
}

/* Input de búsqueda */
.search-input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-input:focus {
    border-color: #007cba;
    box-shadow: 0 2px 12px rgba(0, 124, 186, 0.15);
}

.search-input::placeholder {
    color: #aaa;
    font-weight: 400;
}

/* Botón cerrar */
.close-search-btn {
    position: absolute;
    right: 0;
    top: calc(30px + 1.3rem);
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-search-btn:hover {
    background-color: #f0f0f0;
    color: #666;
}

/* Contenedor de resultados */
.search-results {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
}
@media(max-width:767px) {
    @media(orientation:portrait) {
        .search-results {
            height:calc(100dvh - 110px);
        }
    }
    

}
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Loading */
.search-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Lista de resultados - Grid de tarjetas */
.search-results-list {
    padding: 20px;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding:4px;
}

.search-result-item:hover {
    border-color: rgb(6, 21, 127);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 124, 186, 0.15);
}

/* Imagen del producto */
.result-image >img {
    width: 100%;
    aspect-ratio:1;
    object-fit: cover;
    background: #f8f9fa;
}

.search-result-image-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    font-weight: 500;
}

/* Información del producto */
.search-result-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}
.result-reference {
    font-size: 12px;
}

.search-result-name strong {
    background-color: #fff3cd;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
}

.search-result-description {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    flex: 1;
}

.search-result-price {
    font-size: 16px;
    font-weight: 700;
    color: #e74c3c;
    margin: 8px 0 0 0;
    text-align: center;
}

/* Responsive para tarjetas */
@media (max-width: 768px) {
    .search-results-list {
        padding: 15px;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    
    .search-result-image,
    .search-result-image-placeholder {
        height: 140px;
    }
    
    .search-result-info {
        padding: 12px;
    }
    
    .search-result-name {
        font-size: 13px;
        min-height: 32px;
    }
    
    .search-result-description {
        font-size: 12px;
    }
    
    .search-result-price {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .search-results-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
        padding: 12px;
    }
    
    .search-result-image,
    .search-result-image-placeholder {
        height: 120px;
    }
    
    .search-result-info {
        padding: 10px;
    }
}

/* Animación de entrada para los resultados */
.search-result-item {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

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

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* No results */
.no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Historial de búsqueda */
.search-history {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    max-height: 200px;
    overflow-y: auto;
}

.search-history h4 {
    margin: 0;
    padding: 12px 20px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f1f3f4;
}

.history-item:hover {
    background-color: #e9ecef;
}

.history-item:last-child {
    border-bottom: none;
}

.history-query {
    flex: 1;
    font-weight: 500;
    color: #212529;
}

.history-time {
    font-size: 12px;
    color: #6c757d;
    margin-right: 8px;
}

.history-delete {
    width: 20px;
    height: 20px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-delete:hover {
    background: #c82333;
}

/* NUEVO: Elementos de paginación lazy mejorados */
.search-results-count {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.load-more-indicator {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    border-top: 1px solid #f1f3f4;
    background: linear-gradient(to bottom, #fafbfc, #f8f9fa);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.load-more-indicator p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.scroll-icon {
    animation: bounce 2s infinite;
    font-size: 16px;
    color: #007bff;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

.end-results-indicator {
    padding: 20px;
    text-align: center;
    color: #28a745;
    font-weight: 500;
    border-top: 1px solid #f1f3f4;
    background: linear-gradient(to bottom, #f8fff8, #f0f8f0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.end-results-indicator p {
    margin: 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-more {
    padding: 20px;
    text-align: center;
    color: #007bff;
    font-weight: 500;
    border-top: 1px solid #f1f3f4;
    background: linear-gradient(to bottom, #f8f9ff, #f0f4ff);
}

.loading-more p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading-more p::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid #007bff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Animaciones para nuevos elementos */
.search-result-item {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Responsivo */
@media (max-width: 768px) {
    .dropdown-search-container {
        margin: 0;
        border-radius: 0;
    }
    
    .search-input {
        font-size: 16px; /* Evitar zoom en iOS */
    }
    
    .search-results-list {
        max-height: 60vh;
    }
    
    .history-item {
        padding: 12px 15px;
    }
    
    .history-query {
        font-size: 14px;
    }
}