/**
 * Buscastell Products Search Module - Styles
 * @copyright   Copyright (C) 2026 TacticStudio. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */

/* === Contenedor principal === */
.mod-buscastell-products {
    /* El ancho máximo lo controla el .uk-container-xlarge interno */
}

/* === Barra de búsqueda === */
.buscastell-search-bar {
    position: -webkit-sticky; /* Safari */
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    transition: box-shadow 0.3s ease;
}

.buscastell-search-bar.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Input de búsqueda */
.buscastell-search-input-wrapper {
    position: relative;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.buscastell-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    padding-right: 3rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.buscastell-search-input:focus {
    outline: none;
    border-color: #9d0954;
    box-shadow: 0 0 0 0.2rem rgba(157, 9, 84, 0.25);
}

.buscastell-search-btn,
.buscastell-clear-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: #9d0954;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: 500;
}

.buscastell-search-btn:hover {
    background: #7a0741;
}

.buscastell-clear-btn {
    background: #6c757d;
}

.buscastell-clear-btn:hover {
    background: #5a6268;
}

/* Filtros */
.buscastell-filters-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.buscastell-filter label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
}

.buscastell-filter-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
}

.buscastell-filter-select:focus {
    outline: none;
    border-color: #9d0954;
    box-shadow: 0 0 0 0.2rem rgba(157, 9, 84, 0.25);
}

/* Loading */
.buscastell-loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.buscastell-loading .icon-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Contador de resultados */
.buscastell-results-info {
    margin-bottom: 1.5rem;
    text-align: right;
    color: #6c757d;
    font-size: 0.9rem;
}

/* === Grid de productos === */
.buscastell-products-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
}

/* Responsive columns */
.buscastell-products-grid[data-columns-desktop="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.buscastell-products-grid[data-columns-desktop="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.buscastell-products-grid[data-columns-desktop="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.buscastell-products-grid[data-columns-desktop="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.buscastell-products-grid[data-columns-desktop="6"] {
    grid-template-columns: repeat(6, 1fr);
}

/* Tablet */
@media (max-width: 992px) {
    .buscastell-products-grid[data-columns-tablet="2"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .buscastell-products-grid[data-columns-tablet="3"] {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .buscastell-products-grid[data-columns-tablet="4"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .buscastell-products-grid[data-columns-mobile="1"] {
        grid-template-columns: 1fr;
    }
    
    .buscastell-products-grid[data-columns-mobile="2"] {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .buscastell-filters-wrapper {
        grid-template-columns: 1fr;
    }
    
    .buscastell-search-input-wrapper {
        flex-direction: column;
    }
}

/* === Card de producto === */
.buscastell-product-item {
    width: 100%;
    max-width: 100%;
    min-width: 0; /* Importante para que grid funcione correctamente */
    background: transparent;
}

.buscastell-product-link {
    display: block;
    text-decoration: none !important;
    color: inherit;
    height: 100%;
}

.buscastell-product-link:hover {
    text-decoration: none !important;
}

.buscastell-product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Aspect ratio 1:1 */
    overflow: visible;
    background: transparent;
    margin-bottom: 1rem;
}

.buscastell-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Mantener aspecto de la botella */
    transition: transform 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.buscastell-product-link:hover .buscastell-product-image img {
    transform: scale(1.08);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.buscastell-product-content {
    padding: 0.5rem 0;
    text-align: center;
}

.buscastell-product-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #9d0954;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
    transition: color 0.3s ease;
}

.buscastell-product-link:hover .buscastell-product-title {
    color: #000000;
}

.buscastell-product-meta {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    color: #6c757d;
    text-align: center;
}

.buscastell-product-type {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    font-size: 0.8rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.buscastell-product-winery {
    font-style: italic;
    display: block;
    font-size: 0.85rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sin resultados */
.buscastell-no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
    font-size: 1.1rem;
}

/* Error */
.buscastell-error {
    text-align: center;
    padding: 2rem;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

/* === Paginación === */
.buscastell-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.buscastell-page-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    color: #9d0954;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.buscastell-page-btn:hover:not(:disabled) {
    background: #9d0954;
    color: white;
    border-color: #9d0954;
}

.buscastell-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.buscastell-page-numbers {
    font-size: 1rem;
    font-weight: 500;
}

.buscastell-page-separator {
    margin: 0 0.25rem;
    color: #6c757d;
}

/* === Estilos personalizados para Select2 === */
.select2-container--default .select2-selection--single {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    height: auto;
    padding: 0.5rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0;
    line-height: 1.5;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
}

.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #9d0954;
    box-shadow: 0 0 0 0.2rem rgba(157, 9, 84, 0.25);
}

.select2-results__option--highlighted {
    background-color: #9d0954 !important;
}

.select2-container--default .select2-results__option--selected {
    background-color: rgba(157, 9, 84, 0.1);
}

.select2-dropdown {
    border-color: #9d0954;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid #dee2e6;
}

.select2-search--dropdown .select2-search__field:focus {
    border-color: #9d0954;
    outline: none;
}
