/**
 * 13Node Product Carousel - Frontend Styles
 * Author: 13Node
 * URL: https://13node.com
 */

/* ============================================
   Product Carousel Specific Styles
   ============================================ */

.tnpc-product-carousel-wrapper {
    /* Hereda todos los estilos del carousel principal */
}

/* Remover estilos del contenedor para diseño más simple */
.tnpc-product-item .tnpc-item-inner {
    display: flex;
    flex-direction: column;
    height: auto !important; /* Altura automática según contenido */
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
}

.tnpc-product-item:hover .tnpc-item-inner {
    box-shadow: none !important;
    transform: none !important; /* Sin efecto hover en el contenedor */
}

/* Los items del carousel deben tener altura automática */
.tnpc-product-carousel-wrapper .tnpc-carousel-item {
    align-self: stretch; /* Estirar para igualar alturas entre items */
}

/* ============================================
   Configuración de Columnas
   ============================================ */

/* 2 Columnas */
.tnpc-product-carousel-wrapper.tnpc-columns-2 .tnpc-carousel-item {
    flex: 0 0 calc(50% - 0.75rem);
    min-width: 0;
    max-width: calc(50% - 0.75rem);
}

/* 3 Columnas (default) */
.tnpc-product-carousel-wrapper.tnpc-columns-3 .tnpc-carousel-item {
    flex: 0 0 calc(33.333% - 1rem);
    min-width: 0;
    max-width: calc(33.333% - 1rem);
}

/* 4 Columnas */
.tnpc-product-carousel-wrapper.tnpc-columns-4 .tnpc-carousel-item {
    flex: 0 0 calc(25% - 1.125rem);
    min-width: 0;
    max-width: calc(25% - 1.125rem);
}

/* ============================================
   Product Item Image - CUADRADA Y SIMPLE
   ============================================ */

.tnpc-product-image {
    position: relative;
    background: transparent;
    width: 100%;
    padding-top: 100%; /* Ratio 1:1 - Imagen cuadrada */
    overflow: hidden;
    margin-bottom: 1rem;
}

.tnpc-product-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tnpc-product-image img {
    max-width: 100%;
    max-height: 100%;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    position: relative !important;
    border-radius: 12px;
    transition: transform 0.4s ease;
}

.tnpc-product-item:hover .tnpc-product-image img {
    transform: scale(1.05);
}

/* Product Badges (Sale, Out of Stock) */
.tnpc-product-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tnpc-product-sale {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #ffffff;
}

.tnpc-product-out-of-stock {
    background: #718096;
    color: #ffffff;
}

/* ============================================
   Product Content - TODO CENTRADO
   ============================================ */

.tnpc-product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    text-align: center;
}

/* Ocultar categorías en product carousel para diseño más limpio */
.tnpc-product-category {
    display: none;
}

.tnpc-product-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
    min-height: 3.2rem; /* Altura mínima para 2 líneas */
    max-height: 3.2rem; /* Altura máxima para 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}

.tnpc-product-title a {
    color: #1a202c;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tnpc-product-title a:hover {
    color: #667eea;
}

/* ============================================
   Product Price - CENTRADO
   ============================================ */

.tnpc-product-price {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Solo aplica altura mínima si el precio está visible */
.tnpc-product-price:not(:empty) {
    min-height: 2.2rem;
}

/* Si el precio está vacío, no ocupar espacio */
.tnpc-product-price:empty {
    margin: 0;
    display: none;
}

.tnpc-product-price .price {
    font-size: 1.5rem;
    color: #1a202c;
    line-height: 1;
}

.tnpc-product-price .price del {
    font-size: 1.05rem;
    color: #a0aec0;
    font-weight: 500;
    margin-right: 0.25rem;
}

.tnpc-product-price .price ins {
    text-decoration: none;
    color: #667eea;
    font-weight: 700;
}

.tnpc-product-price .woocommerce-Price-amount {
    font-weight: 700;
}

/* ============================================
   Product Rating - CENTRADO
   ============================================ */

.tnpc-product-rating {
    margin: 0 0 1.25rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Solo aplica altura mínima si el rating está visible */
.tnpc-product-rating:not(:empty) {
    min-height: 1.2rem;
}

/* Si el rating está vacío, no ocupar espacio */
.tnpc-product-rating:empty {
    margin: 0;
    display: none;
}

.tnpc-product-rating .star-rating {
    font-size: 0.9rem;
    color: #fbbf24;
    margin: 0 auto;
}

.tnpc-product-rating .star-rating::before {
    color: #e2e8f0;
}

/* ============================================
   Product Actions (Add to Cart)
   ============================================ */

.tnpc-product-actions {
    margin-top: auto;
}

/* Si las acciones están vacías, no ocupar espacio */
.tnpc-product-actions:empty {
    display: none;
}

.tnpc-product-actions .button,
.tnpc-product-actions .added_to_cart {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.25);
    text-align: center;
    min-height: 3rem;
}

.tnpc-product-actions .button:hover,
.tnpc-product-actions .added_to_cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.tnpc-product-actions .button:active {
    transform: translateY(0);
}

.tnpc-product-actions .added_to_cart {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    box-shadow: 0 2px 12px rgba(72, 187, 120, 0.25);
    margin-top: 0.5rem;
}

.tnpc-product-actions .added_to_cart:hover {
    background: linear-gradient(135deg, #38a169 0%, #48bb78 100%);
    box-shadow: 0 4px 20px rgba(72, 187, 120, 0.4);
}

/* Loading state */
.tnpc-product-actions .button.loading {
    opacity: 0.7;
    pointer-events: none;
}

.tnpc-product-actions .button.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 0.5rem;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tnpc-spin 0.6s linear infinite;
}

@keyframes tnpc-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Product link (cuando está oculto el botón de comprar) */
.tnpc-product-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #667eea !important;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none !important;
    transition: gap 0.3s ease, color 0.2s ease;
    margin-top: auto;
}

.tnpc-product-link:hover {
    color: #764ba2 !important;
    gap: 0.75rem;
}

.tnpc-product-link svg {
    transition: transform 0.3s ease;
}

.tnpc-product-link:hover svg {
    transform: translateX(3px);
}

/* ============================================
   Variable Products
   ============================================ */

.tnpc-product-actions .product_type_variable {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.tnpc-product-actions .product_type_variable:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* ============================================
   Grouped Products
   ============================================ */

.tnpc-product-actions .product_type_grouped {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.tnpc-product-actions .product_type_grouped:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* ============================================
   External Products
   ============================================ */

.tnpc-product-actions .product_type_external {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.tnpc-product-actions .product_type_external:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* ============================================
   Out of Stock Products
   ============================================ */

.tnpc-product-item .out-of-stock {
    opacity: 0.6;
}

.tnpc-product-item .out-of-stock .tnpc-product-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

/* ============================================
   Custom Color Support
   ============================================ */

/* Los colores personalizados se aplicarán automáticamente
   desde el CSS generado en el archivo principal */

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    /* En tablets, todas las configuraciones se reducen */
    .tnpc-product-carousel-wrapper.tnpc-columns-4 .tnpc-carousel-item {
        flex: 0 0 calc(33.333% - 1rem);
        max-width: calc(33.333% - 1rem);
    }
}

@media (max-width: 768px) {
    /* En tablets pequeños, máximo 2 columnas */
    .tnpc-product-carousel-wrapper.tnpc-columns-3 .tnpc-carousel-item,
    .tnpc-product-carousel-wrapper.tnpc-columns-4 .tnpc-carousel-item {
        flex: 0 0 calc(50% - 0.75rem);
        max-width: calc(50% - 0.75rem);
    }

    .tnpc-product-image {
        margin-bottom: 0.75rem;
    }

    .tnpc-product-title {
        font-size: 1.05rem;
        min-height: 2.8rem;
        max-height: 2.8rem;
        margin-bottom: 0.5rem;
    }

    .tnpc-product-price .price {
        font-size: 1.35rem;
    }

    .tnpc-product-price:not(:empty) {
        min-height: 2rem;
        margin-bottom: 0.5rem;
    }

    .tnpc-product-rating:not(:empty) {
        margin-bottom: 1rem;
    }

    .tnpc-product-actions .button,
    .tnpc-product-actions .added_to_cart {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        min-height: 2.8rem;
    }

    .tnpc-product-badge {
        top: 0.4rem;
        left: 0.4rem;
        padding: 0.3rem 0.65rem;
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    /* En móviles, siempre 1 columna */
    .tnpc-product-carousel-wrapper .tnpc-carousel-item {
        flex: 0 0 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    .tnpc-product-image {
        margin-bottom: 0.5rem;
    }

    .tnpc-product-title {
        font-size: 1rem;
        min-height: 2.6rem;
        max-height: 2.6rem;
        margin-bottom: 0.5rem;
    }

    .tnpc-product-price .price {
        font-size: 1.25rem;
    }

    .tnpc-product-price:not(:empty) {
        min-height: 1.8rem;
        margin-bottom: 0.5rem;
    }

    .tnpc-product-rating:not(:empty) {
        margin-bottom: 0.75rem;
    }

    .tnpc-product-actions .button,
    .tnpc-product-actions .added_to_cart {
        padding: 0.7rem 1.1rem;
        font-size: 0.875rem;
        min-height: 2.6rem;
    }

    .tnpc-product-badge {
        top: 0.3rem;
        left: 0.3rem;
        padding: 0.25rem 0.55rem;
        font-size: 0.55rem;
    }
}

/* ============================================
   Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .tnpc-product-actions .button,
    .tnpc-product-actions .added_to_cart {
        transition: none;
    }
}

/* Focus styles for keyboard navigation */
.tnpc-product-actions .button:focus-visible,
.tnpc-product-actions .added_to_cart:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}
