/* =====================================================
   POPUP DE VARIACIONES Y PRODUCTOS AGRUPADOS
   ===================================================== */

/* Estructura principal del popup */
.product-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
}

/* Overlay oscuro */
.product-popup-modal .popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    animation: fadeIn 0.3s ease;
}

/* Contenedor principal */
.product-popup-modal .popup-container {
    position: relative;
    max-width: 1200px;
    max-height: 90vh;
    width: 90%;
    margin: 5vh auto;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

/* Botón de cerrar */
.product-popup-modal .popup-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.product-popup-modal .popup-close:hover {
    background: #f5f5f5;
    transform: rotate(90deg);
}

.product-popup-modal .popup-close span {
    font-size: 24px;
    line-height: 1;
    color: #333;
}

/* Contenido del popup */
.product-popup-modal .popup-content {
    position: relative;
    height: calc(90vh - 40px);
    overflow-y: auto;
    padding: 20px;
}

/* Loading state */
.popup-loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

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

.popup-loading p {
    color: #666;
    font-size: 16px;
}

/* Wrapper del producto */
.popup-product-wrapper {
    display: flex;
    gap: 40px;
    padding: 20px;
}

/* Sección de imágenes */
.popup-product-images {
    flex: 0 0 50%;
    max-width: 50%;
}

.popup-gallery {
    position: sticky;
    top: 20px;
}

.popup-main-image {
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.popup-main-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Thumbnails */
.popup-thumbnails {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.popup-thumbnails .thumb-item {
    flex: 0 0 80px;
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.popup-thumbnails .thumb-item:hover,
.popup-thumbnails .thumb-item.active {
    border-color: #333;
}

.popup-thumbnails .thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Detalles del producto */
.popup-product-details {
    flex: 1;
}

/* Header del producto */
.popup-product-header {
    margin-bottom: 25px;
}

.popup-breadcrumb {
    font-size: 13px;
    color: #999;
    margin-bottom: 10px;
}

.popup-breadcrumb a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s;
}

.popup-breadcrumb a:hover {
    color: #333;
}

.popup-breadcrumb span {
    margin: 0 8px;
    color: #ccc;
}

.popup-product-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0 0 20px;
    line-height: 1.3;
}

/* Descripción */
.popup-product-description {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.6;
}

/* Precio */
.popup-product-price {
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.popup-product-price del {
    color: #999;
    font-weight: 400;
    font-size: 18px;
    margin-right: 10px;
}

.popup-product-price ins {
    text-decoration: none;
    color: #e74c3c;
}

/* Stock */
.popup-product-stock {
    margin-bottom: 25px;
    padding: 10px 15px;
    border-radius: 4px;
    display: inline-block;
}

.popup-product-stock.in-stock {
    background: #d4edda;
    color: #155724;
}

.popup-product-stock.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* Formulario de variaciones */
.popup-product-form .variations {
    margin-bottom: 20px;
    width: 100%;
}

.popup-product-form .variations tbody {
    display: block;
}

.popup-product-form .variations tr {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    width: 100%;
}

.popup-product-form .variations td {
    padding: 10px 15px 10px 0;
    vertical-align: middle;
    display: block;
}

.popup-product-form .variations td.label {
    font-weight: 600;
    color: #333;
    min-width: 120px;
    flex: 0 0 120px;
}

.popup-product-form .variations td.value {
    flex: 1;
    width: 100%;
}

/* Asegurar que los selectores de variación sean clickeables */
.popup-product-form .variations select,
.popup-product-form .variations input,
.popup-product-form .variations .ts-selector-wrapper,
.popup-product-form .variations .variation-selector {
    position: relative;
    z-index: 10;
    pointer-events: auto !important;
}

/* Mantener los estilos nativos del tema para variaciones */
.popup-product-form .variations,
.popup-product-form .variations_form {
    /* Heredar estilos del tema */
}

/* Solo ajustes mínimos para el popup */
.popup-product-form .single_variation_wrap {
    margin-top: 20px;
}

/* Mantener compatibilidad con plugins de swatches existentes */
.popup-product-form .ts-product-attribute,
.popup-product-form .variation-swatches,
.popup-product-form .color-swatch,
.popup-product-form .image-swatch,
.popup-product-form .label-swatch {
    /* Los estilos del tema/plugins se aplicarán automáticamente */
}

/* Select dropdowns */
.popup-product-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* Quantity input */
.popup-product-form .quantity {
    display: inline-block;
    margin-right: 15px;
}

.popup-product-form .quantity input {
    width: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

/* Botón añadir al carrito */
.popup-product-form .single_add_to_cart_button {
    background: #333;
    color: #fff !important;
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.popup-product-form .single_add_to_cart_button:hover {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.popup-product-form .single_add_to_cart_button.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.popup-product-form .single_add_to_cart_button.loading::after {
    content: '...';
    display: inline-block;
    animation: dots 1.5s steps(4, end) infinite;
}

/* Ocultar botón Buy Now en el popup */
.popup-product-form .merto-buy-now,
.popup-product-form .ts-buy-now-button,
.popup-product-form button[name="merto-buy-now"] {
    display: none !important;
}

/* Asegurar que el contenido del popup sea clickeable */
.popup-product-form * {
    position: relative;
}

/* Mejorar z-index para variaciones del tema Merto */
.popup-product-form .ts-product-attribute .options-wrapper,
.popup-product-form .ts-product-attribute .option {
    position: relative;
    z-index: 100;
    cursor: pointer;
}

/* Tabla de productos agrupados */
.woocommerce-grouped-product-list {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
}

.woocommerce-grouped-product-list td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.woocommerce-grouped-product-list tr:last-child td {
    border-bottom: none;
}

.woocommerce-grouped-product-list-item__quantity {
    width: 100px;
}

.woocommerce-grouped-product-list-item__quantity input {
    width: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.woocommerce-grouped-product-list-item__label {
    font-weight: 500;
    color: #333;
}

.woocommerce-grouped-product-list-item__price {
    text-align: right;
    font-weight: 600;
    color: #333;
}

/* Notificaciones */
.popup-notification {
    position: absolute;
    top: 20px;
    right: 60px;
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    animation: slideInRight 0.3s ease;
}

.popup-notification.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.popup-notification.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* Body class cuando el popup está abierto */
body.popup-open {
    overflow: hidden;
}

/* Botón en productos agrupados */
.woocommerce-grouped-product-list a.grouped-variable-popup {
    display: inline-block;
    padding: 8px 16px;
    background: #333;
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.woocommerce-grouped-product-list a.grouped-variable-popup:hover {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Responsive para tablets */
@media (max-width: 992px) {
    .product-popup-modal .popup-container {
        width: 95%;
        max-height: 95vh;
        margin: 2.5vh auto;
    }

    .popup-product-wrapper {
        flex-direction: column;
        gap: 30px;
    }

    .popup-product-images {
        flex: none;
        max-width: 100%;
    }

    .popup-gallery {
        position: relative;
        top: auto;
    }
}

/* Responsive para móviles */
@media (max-width: 576px) {
    .product-popup-modal .popup-container {
        width: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .product-popup-modal .popup-content {
        padding: 15px;
        height: 100vh;
    }

    .popup-product-wrapper {
        padding: 10px;
    }

    .popup-product-title {
        font-size: 22px;
    }

    .popup-product-price {
        font-size: 20px;
    }

    .popup-thumbnails .thumb-item {
        flex: 0 0 60px;
        width: 60px;
        height: 60px;
    }

    .popup-product-form .variations td {
        display: block;
        width: 100%;
        padding: 5px 0;
    }

    .popup-product-form .variations .label {
        width: auto;
        margin-bottom: 5px;
    }

    .single_add_to_cart_button {
        width: 100%;
        padding: 15px;
    }

    .popup-notification {
        right: 20px;
        left: 20px;
        text-align: center;
    }

    .woocommerce-grouped-product-list {
        font-size: 14px;
    }

    .woocommerce-grouped-product-list td {
        padding: 8px;
    }
}