/* Contenedor principal */
.advanced-product-search {
    --primary-color: #333;
    --border-color: #ddd;
    --hover-color: #f5f5f5;
    --shadow-color: rgba(0, 0, 0, 0.1);
    max-width: 100%;
    margin: 0 auto;
}

/* Buscador */
.search-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search-container {
    position: relative;
}

.product-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.product-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
}

.search-clear > svg{
    width: 26px;
    position: absolute;
    margin-top: 7px;
}

/* Lista de resultados */
.search-results-wrapper {     
    margin-top: 10px;
    background: white;
    border-radius: 8px;
}

.results-count {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    color: #666;
    font-size: 14px;
}

.search-results-grid {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.search-clear {
    position: absolute;
    right: 39px;
    top: 0%;
    transform: translateY(-50%);
    cursor: pointer;
    display: none; /* Oculto por defecto */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.search-container.has-value .search-clear {
    display: block;
    opacity: 1;
}

.search-container.has-value .search-icon {
    display: none;
}

.search-icon > svg{
    width: 1.1em;
    height: 1.1em;
}

/* Ajustar el loader para que no se superponga con el icono de limpiar */
.search-container.has-value .search-loader {
    right: 45px;
}

.product-result-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.product-result-item:hover {
    background-color: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.product-result-image {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    margin-right: 15px;
    border-radius: 4px;
    overflow: hidden;
    background: #f8f8f8;
}

.product-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-result-details {
    flex: 1;
}

.product-result-title {
    font-size: 15px;
    font-weight: 500;
    margin: 0 0 8px;
    color: var(--primary-color);
}

.product-result-price {
    font-size: 14px;
    color: var(--primary-color);
}

.product-result-price del {
    color: #999;
    margin-right: 8px;
}

.product-result-price ins {
    text-decoration: none;
    font-weight: 600;
    color: #e4022d;
}

/* Modal */
.product-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    overflow: hidden;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.modal-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    margin: 5vh auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
}

.product-modal.active .modal-container {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    position: relative;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
}

.modal-close:hover {
    background: var(--hover-color);
}

.modal-close svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.modal-content {
    padding: 20px;
    max-height: calc(90vh - 60px);
    overflow-y: auto;
}

/* Contenido del modal */
.modal-product-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .modal-product-content {
        grid-template-columns: 1fr;
    }
}

.modal-product-gallery {
    position: relative;
}

.modal-product-gallery img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.modal-product-gallery-thumbs {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.modal-product-gallery-thumbs img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.modal-product-gallery-thumbs img:hover {
    opacity: 1;
}

.modal-product-details {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-product-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
    color: var(--primary-color);
}

.modal-product-price {
    font-size: 20px;
    color: #e4022d;
    font-weight: 600;
}

.modal-product-description {
    color: #666;
    line-height: 1.6;
}

.modal-cart-form {
    margin-top: 20px;
}

.quantity {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.quantity input {
    width: 60px;
    text-align: center;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
}

.single_add_to_cart_button {
    width: 100%;
    padding: 12px 24px;
    background: #e4022d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.single_add_to_cart_button:hover {
    background: #c60227;
}

/* Loader */
.search-loader {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.advanced-product-search.loading .search-loader {
    display: block;
}

.advanced-product-search.loading .search-icon {
    display: none;
}

.loader-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Paginación */
.product-search-pagination {
    display: flex;
    justify-content: center;
    padding: 20px;
    gap: 5px;
}

.page-number {
    min-width: 35px;
    height: 35px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--primary-color);
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.page-number.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-number:hover:not(.active) {
    background: var(--hover-color);
}

/* Responsive */
@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        margin: 2.5vh auto;
    }

    .product-result-image {
        width: 60px;
        height: 60px;
    }

    .product-result-title {
        font-size: 14px;
    }

    .modal-product-gallery-thumbs {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}