/* ============================================
   RETROFASE PRODUCT GRID - Estilos RESPONSIVE
   ============================================
   
   Sistema de tarjetas de productos 100% adaptable
   - Grid adaptativo según espacio disponible
   - Sin restricciones de ancho máximo
   - Se adapta al contenedor padre en Divi
   
   ============================================ */

/* ============================================
   1. CONTENEDOR PRINCIPAL
   ============================================ */

.retrofase-product-grid-wrapper {
    width: 100%;
    max-width: none; /* ← ELIMINADO: restricción fija */
    margin: 0 auto;
    padding: clamp(20px, 4vw, 40px) clamp(15px, 3vw, 20px); /* ← MEJORADO: padding responsive */
    opacity: 1;
    box-sizing: border-box; /* ← AGREGADO: incluir padding en width */
    container-type: inline-size; /* ← AGREGADO: container queries */
}

/* ============================================
   2. HEADER DE FILTROS
   ============================================ */

.product-filters-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.product-filters-header .filter-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.product-filters-header .filter-title {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    color: #2D3748;
    padding-top: 10px;
    margin: 0;
}

/* ============================================
   3. FILTROS DE CATEGORÍAS
   ============================================ */

.product-filters-container {
    width: 100%;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.product-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    min-height: 44px;
    padding-bottom: 10px;
    padding-top: 10px;
}

.filter-btn {
    height: 44px;
    padding: 0 24px;
    background: #FFFFFF;
    border: 2px solid #EAEBED;
    border-radius: 22px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-btn-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.filter-btn:hover {
    background: #F5F5F5;
    border-color: #034AB1;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: #034AB1;
    border-color: #034AB1;
    color: #FFFFFF;
    font-weight: 700;
}

/* Invertir color del ícono cuando el botón está activo */
.filter-btn.active .filter-btn-icon {
    filter: brightness(0) invert(1);
}

.filter-btn:focus {
    outline: 2px solid #034AB1;
    outline-offset: 2px;
}

/* ============================================
   4. CONTADOR DE RESULTADOS
   ============================================ */

.product-results-counter {
    width: 100%;
    max-width: none; /* ← ELIMINADO: restricción fija */
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 21px;
    margin-bottom: 40px;
    background: #EFEFEF;
    border: 1px solid #E2E8F0;
    border-radius: 20px;
    box-sizing: border-box; /* ← AGREGADO: manejo correcto padding */
}

.product-results-counter .results-text {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #2D3748;
}

.product-results-counter .results-count {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 14px;
    line-height: 20px;
    color: #2D3748;
}

/* ============================================
   5. GRID DE PRODUCTOS - ADAPTATIVO
   ============================================ */

.retrofase-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); /* ← MEJORADO: grid adaptativo */
    gap: clamp(16px, 2.5vw, 24px); /* ← MEJORADO: gap responsive */
    margin-bottom: 40px;
    width: 100%; /* ← AGREGADO: asegurar width completo */
}

/* ============================================
   6. TARJETA DE PRODUCTO - FLEXIBLE
   ============================================ */

.product-card {
    width: 100%; /* ← CAMBIADO: usar todo el espacio del grid */
    max-width: none; /* ← ELIMINADO: restricción fija */
    min-height: 420px;
    height: auto;
    background: #FFFFFF;
    border: 2px solid #EAEBED;
    border-radius: 24px;
    padding: 2px;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    justify-self: center;
    display: flex;
    flex-direction: column;
    box-shadow: 0px 0px 12.5px 4px #FFFFFFA8;
    box-sizing: border-box; /* ← AGREGADO: manejo correcto de padding */
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.12);
    border-color: #034AB1;
}

.product-card-inner {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ============================================
   7. IMAGEN DEL PRODUCTO - RESPONSIVE
   ============================================ */

.product-image-wrapper {
    width: 100%; /* ← CAMBIADO: usar ancho completo */
    height: auto; /* ← CAMBIADO: altura automática */
    aspect-ratio: 16 / 10; /* ← AGREGADO: ratio consistente */
    position: relative;
    overflow: hidden;
    border-radius: 22px 22px 0 0;
    flex-shrink: 0;
}

.product-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.product-image-wrapper img {
    width: 100%; /* ← CAMBIADO: imagen completa */
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image-wrapper img {
    transform: scale(1.02);
}

/* ============================================
   8. BADGE DE OFERTA
   ============================================ */

.product-sale-badge {
    position: absolute;
    top: 16px;
    left: 16.25px;
    width: 72px;
    height: 30px;
    background: #A10D1F;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    gap: 4px;
    z-index: 2;
}

.product-sale-badge span {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: #FFFFFF;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   9. CONTENIDO DE LA TARJETA
   ============================================ */

.product-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px 24px;
    gap: 8px;
}

/* ============================================
   10. BADGE DE CATEGORÍA
   ============================================ */

.product-category-badge {
    height: 20px;
    padding: 2px 10px;
    background: #F5F5F5;
    border: 1px solid #EAEBED;
    border-radius: 33554400px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.product-category-badge span {
    font-family: 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 11px;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   11. TÍTULO DEL PRODUCTO
   ============================================ */

.product-title {
    margin: 0;
    padding: 0 8px;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-title a {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 20px;
    color: #333333;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.product-title a:hover {
    color: #034AB1;
}

/* ============================================
   12. PRECIO DEL PRODUCTO
   ============================================ */

.product-price-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 0;
}

.product-price,
.product-price-sale {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 24px;
    line-height: 32px;
    color: #333333;
}

.product-price-regular {
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 24px;
    color: #999999;
    text-decoration: line-through;
}

.product-price-sale {
    color: #A10D1F;
}

/* ============================================
   13. BOTÓN AGREGAR AL CARRITO - RESPONSIVE (CORREGIDO)
   ============================================ */

.product-add-to-cart {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.product-card .button,
.product-card .add_to_cart_button,
.product-card .product_type_simple {
    width: min(227px, calc(100% - 20px)) !important;
    max-width: 227px !important;
    height: 39px !important;
    background: #034AB1 !important;
    border: none !important;
    border-radius: 16px !important;
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #FFFFFF !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    padding: 0 20px !important;
    margin: 0 !important;
    position: relative !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

.product-card .button:hover,
.product-card .add_to_cart_button:hover {
    background: #023a8f !important;
    transform: translateY(-2px) !important;
    box-shadow: 0px 4px 12px rgba(3, 74, 177, 0.3) !important;
}

/* ============================================
   ÍCONO DEL CARRITO - MÉTODO SIMPLIFICADO
   ============================================ */

.product-card .button::before,
.product-card .add_to_cart_button::before,
.product-card .product_type_simple::before {
    content: '🛒' !important;
    font-size: 16px !important;
    margin-right: 8px !important;
    display: inline-block !important;
    opacity: 1 !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

/* ============================================
   REMOVER ICONOS DE DIVI COMPLETAMENTE
   ============================================ */

.product-card .button::after,
.product-card .add_to_cart_button::after,
.product-card .product_type_simple::after,
.retrofase-product-grid .product-card .button::after,
.retrofase-product-grid .product-card .add_to_cart_button::after {
    content: none !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Remover elementos internos de Divi que puedan interferir */
.product-card .button .et_pb_button_wrapper,
.product-card .button i,
.product-card .add_to_cart_button i,
.product-card .button span:not(.cart-text),
.product-card .add_to_cart_button span:not(.cart-text) {
    display: none !important;
}

/* ============================================
   LOADING STATE MEJORADO
   ============================================ */

.product-card .button.loading,
.product-card .add_to_cart_button.loading {
    pointer-events: none !important;
    opacity: 0.8 !important;
    cursor: wait !important;
}

/* Loader como ::before cuando está loading */
.product-card .button.loading::before,
.product-card .add_to_cart_button.loading::before {
    content: '' !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid transparent !important;
    border-top: 2px solid #ffffff !important;
    border-radius: 50% !important;
    animation: retrofaseSpinLoader 0.8s linear infinite !important;
    margin-right: 8px !important;
    margin-left: 0 !important;
    font-size: 0 !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

/* Animación personalizada del loader */
@keyframes retrofaseSpinLoader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Texto del botón cuando está loading */
.product-card .button.loading .cart-text,
.product-card .add_to_cart_button.loading .cart-text {
    opacity: 0.9 !important;
}

/* ============================================
   ENLACE "VER CARRITO" - SIN ICONO DE OJO
   ============================================ */

.product-card .added_to_cart {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: min(227px, calc(100% - 20px)) !important;
    max-width: 227px !important;
    height: 36px !important;
    background: #FFFFFF !important;
    border: 2px solid #034AB1 !important;
    border-radius: 16px !important;
    font-family: 'Open Sans', sans-serif !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #034AB1 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    margin-top: 0 !important;
    padding: 0 20px !important;
    position: relative !important;
    box-sizing: border-box !important;
}

.product-card .added_to_cart:hover {
    background: #034AB1 !important;
    color: #FFFFFF !important;
    transform: translateY(-2px) !important;
    box-shadow: 0px 4px 12px rgba(3, 74, 177, 0.3) !important;
}

/* REMOVER el ícono de ojo completamente */
.product-card .added_to_cart::before {
    display: none !important;
    content: none !important;
}

/* ============================================
   ESTADO "AGREGADO" CON FEEDBACK VISUAL
   ============================================ */

.product-card .button.added,
.product-card .add_to_cart_button.added {
    background: #28a745 !important;
    transform: scale(1.05) !important;
}

.product-card .button.added::before,
.product-card .add_to_cart_button.added::before {
    content: '✓' !important;
    animation: none !important;
    border: none !important;
    width: auto !important;
    height: auto !important;
    font-size: 16px !important;
}

/* ============================================
   RESPONSIVE - BOTONES EN MÓVIL
   ============================================ */

@media (max-width: 768px) {
    .product-card .button,
    .product-card .add_to_cart_button,
    .product-card .added_to_cart {
        width: calc(100% - 16px) !important;
        max-width: none !important;
    }
}

@media (max-width: 576px) {
    .product-card .button,
    .product-card .add_to_cart_button,
    .product-card .added_to_cart {
        width: calc(100% - 12px) !important;
        font-size: 13px !important;
        height: 36px !important;
    }
    
    .product-card .button::before,
    .product-card .add_to_cart_button::before {
        font-size: 14px !important;
        margin-right: 6px !important;
    }
}

/* ============================================
   COMPATIBILIDAD Y FORZADO FINAL
   ============================================ */

/* FORZAR visibilidad del contenido del botón */
.retrofase-product-grid .product-card .button,
.retrofase-product-grid .product-card .add_to_cart_button {
    text-indent: 0 !important;
    white-space: nowrap !important;
    overflow: visible !important;
}

/* Asegurar que el texto sea visible */
.product-card .button > span,
.product-card .add_to_cart_button > span {
    display: inline !important;
    opacity: 1 !important;
    color: inherit !important;
}

/* ============================================
   14. ESTADOS DE CARGA
   ============================================ */

.products-loading {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #034AB1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.products-loading p {
    font-family: 'Open Sans', sans-serif;
    font-size: 24px;
    color: white;
}

.no-products-found {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.no-products-found p {
    font-family: 'Open Sans', sans-serif;
    font-size: 18px;
    color: #666666;
}

/* ============================================
   15. CONTAINER QUERIES - CONTROL AVANZADO
   ============================================ */

/* Grid adaptativo basado en el contenedor padre */
@container (max-width: 900px) {
    .retrofase-product-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: clamp(12px, 2vw, 20px);
    }
}

@container (max-width: 600px) {
    .retrofase-product-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .retrofase-product-grid-wrapper {
        padding: clamp(16px, 3vw, 24px) clamp(12px, 2.5vw, 16px);
    }
}

@container (max-width: 400px) {
    .product-card .button,
    .product-card .add_to_cart_button,
    .product-card .added_to_cart {
        width: calc(100% - 16px) !important;
        max-width: none !important;
    }
}

/* ============================================
   16. MEDIA QUERIES - RESPALDO UNIVERSAL
   ============================================ */

/* TABLET - Grid adaptativo */
@media (max-width: 1024px) {
    .retrofase-product-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .retrofase-product-grid-wrapper {
        padding: 30px 15px;
    }
    
    .product-filters-header {
        margin-bottom: 16px;
    }
    
    .product-filters-container {
        margin-bottom: 20px;
    }
    
    .product-results-counter {
        margin-bottom: 30px;
        padding: 0 16px;
    }
}

/* MOBILE - 1 columna fija */
@media (max-width: 768px) {
    .retrofase-product-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .retrofase-product-grid-wrapper {
        padding: 20px 12px;
    }
    
    .product-filters-header {
        margin-bottom: 16px;
    }
    
    .product-filters-header .filter-icon {
        width: 20px;
        height: 20px;
    }
    
    .product-filters-header .filter-title {
        font-size: 16px;
        line-height: 22px;
    }
    
    .product-filters-container {
        margin-bottom: 16px;
    }
    
    .product-filters {
        gap: 8px;
    }
    
    .filter-btn {
        height: 40px;
        padding: 0 20px;
        font-size: 13px;
    }
    
    .product-results-counter {
        margin-bottom: 24px;
        padding: 0 16px;
        height: 40px;
    }
    
    .product-results-counter .results-text {
        font-size: 13px;
    }
    
    .product-results-counter .results-count {
        font-size: 13px;
    }
    
    .product-card {
        max-width: 100%;
        min-height: 420px;
        height: auto;
    }
}

@media (max-width: 576px) {
    .retrofase-product-grid-wrapper {
        padding: 16px 10px;
    }
    
    .filter-btn {
        height: 38px;
        padding: 0 16px;
        font-size: 12px;
    }
    
    /* Botones más estrechos en móvil muy pequeño */
    .product-card .button,
    .product-card .add_to_cart_button,
    .product-card .added_to_cart {
        width: calc(100% - 12px) !important;
        max-width: none !important;
        font-size: 13px !important;
    }
}

/* ============================================
   17. ACCESIBILIDAD Y COMPATIBILIDAD
   ============================================ */

/* FORZAR VISIBILIDAD DEL ÍCONO - Reglas adicionales */
.retrofase-product-grid-wrapper .product-card .button::before,
.retrofase-product-grid-wrapper .product-card .add_to_cart_button::before {
    content: '' !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    background: url('https://staging.retrofase.cl/wp-content/uploads/2025/11/Cart-Icon-Retrofase.png') center/contain no-repeat !important;
    filter: brightness(0) invert(1) !important;
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
    order: -1 !important;
    margin-right: 6px !important;
    position: relative !important;
    z-index: 1 !important;
}

.product-card:focus-within {
    outline: 2px solid #034AB1;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Soporte para navegadores legacy */
@supports not (container-type: inline-size) {
    .retrofase-product-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* ============================================
   FIN DE ESTILOS RESPONSIVE
   ============================================ */


   /* ============================================
   RETROFASE VARIABLE PRODUCTS - CSS ADICIONAL
   ============================================ */

/* ============================================
   BOTÓN "VER OPCIONES" PARA PRODUCTOS VARIABLES
   ============================================ */

.product-card .product_type_variable {
    background: #e3ba5d !important; /* Color dorado para variables */
    border: none !important;
}

.product-card .product_type_variable:hover {
    background: #d4a941 !important; /* Dorado más oscuro en hover */
    transform: translateY(-2px) !important;
    box-shadow: 0px 4px 12px rgba(227, 186, 93, 0.4) !important;
}

.product-card .product_type_variable .button-icon {
    font-size: 16px !important;
    margin-right: 8px !important;
}

/* ============================================
   BOTÓN "AÑADIR AL CARRITO" PARA PRODUCTOS SIMPLES
   ============================================ */

.product-card .product_type_simple,
.product-card .add_to_cart_button {
    background: #034AB1 !important; /* Azul para productos simples */
}

.product-card .product_type_simple:hover,
.product-card .add_to_cart_button:hover {
    background: #023a8f !important;
    transform: translateY(-2px) !important;
    box-shadow: 0px 4px 12px rgba(3, 74, 177, 0.3) !important;
}

/* ============================================
   ICONOS ESPECÍFICOS POR TIPO
   ============================================ */

/* Ícono para productos variables */
.product-card .product_type_variable .button-icon::before {
    content: '👁️' !important;
}

/* Ícono para productos simples */
.product-card .product_type_simple .button-icon::before,
.product-card .add_to_cart_button .button-icon::before {
    content: '🛒' !important;
}

/* Remover emoji directo cuando hay ::before */
.product-card .button-icon:not(:empty)::before {
    display: none !important;
}

/* ============================================
   PRECIOS "DESDE" PARA PRODUCTOS VARIABLES
   ============================================ */

.product-card .product-price-wrapper .woocommerce-Price-amount {
    color: #034AB1 !important;
    font-weight: 700 !important;
}

/* Badge especial para productos variables */
.product-card[data-product-type="variable"] .product-category-badge {
    background: #e3ba5d !important;
    color: #FFFFFF !important;
    border-color: #e3ba5d !important;
}

.product-card[data-product-type="variable"] .product-category-badge::after {
    content: " (Variable)" !important;
    font-size: 9px !important;
    opacity: 0.8 !important;
}

/* ============================================
   RESPONSIVE PARA BOTONES VARIABLES
   ============================================ */

@media (max-width: 768px) {
    .product-card .product_type_variable,
    .product-card .product_type_simple {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        font-size: 13px !important;
    }
}

/* ============================================
   LOADING STATES DIFERENCIADOS
   ============================================ */

/* Variables no tienen loading (van a otra página) */
.product-card .product_type_variable.loading {
    opacity: 0.9 !important;
    pointer-events: auto !important;
}

.product-card .product_type_variable.loading::before {
    display: none !important;
}

/* Solo productos simples tienen loading state */
.product-card .product_type_simple.loading::before,
.product-card .add_to_cart_button.loading::before {
    content: '' !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid transparent !important;
    border-top: 2px solid #ffffff !important;
    border-radius: 50% !important;
    animation: retrofaseSpinLoader 0.8s linear infinite !important;
    margin-right: 8px !important;
    display: inline-block !important;
}

/* Ocultar sufijo de precio duplicado */
.product-card .woocommerce-price-suffix {
    display: none !important;
}

.price-iva-label {
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    align-self: center;
}