/**
 * Estilos para productos en combo/cajas en el Carrito y Checkout
 * Compatible con WooCommerce Clásico y WooCommerce Cart Blocks (Gutenberg / React)
 */

/* ==========================================================================
   1. Carrito Clásico (Tabla)
   ========================================================================== */

.woocommerce-cart-form table.cart tr.batllie-combo-item {
    background-color: #fafaf9;
}

.woocommerce-cart-form table.cart tr.batllie-combo-box-item {
    background-color: #f0fdf4 !important;
    font-weight: 600;
    border-left: 4px solid #065f46 !important;
}

.woocommerce-cart-form table.cart tr.batllie-combo-child-item {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
}

/* Ocultar botones de incremento/decremento en ítems de combo */
.batllie-combo-item .quantity input.qty::-webkit-inner-spin-button,
.batllie-combo-item .quantity input.qty::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.batllie-combo-item .emp-qty-btn,
.batllie-combo-item .plus,
.batllie-combo-item .minus {
    display: none !important;
    pointer-events: none !important;
}

.batllie-combo-item .quantity input.qty {
    pointer-events: none !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 600;
    text-align: center;
}

/* Badges y precios clásicos */
.batllie-combo-price {
    font-weight: 700;
    color: #0f172a;
}

.batllie-free-price {
    font-weight: 700;
    color: #059669;
}

.batllie-included-in-box {
    font-size: 12px;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 9999px;
    padding: 2px 8px;
    display: inline-block;
    margin-top: 4px;
}

.woocommerce-cart-form table.cart tr.batllie-combo-child-item td.product-remove,
.woocommerce-cart-form table.cart tr.batllie-combo-child-item .product-remove a.remove {
    display: none !important;
    visibility: hidden !important;
}

.woocommerce-cart-form table.cart tr.batllie-combo-child-item td.product-price,
.woocommerce-cart-form table.cart tr.batllie-combo-child-item td.product-subtotal {
    display: none !important;
    visibility: hidden !important;
}


/* ==========================================================================
   2. WooCommerce Cart Block (Gutenberg / React)
   ========================================================================== */

/* Tarjeta Principal: Caja de Empaque */
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box,
.wc-block-cart-item.batllie-is-combo-box {
    border: 1.5px solid #10b981 !important;
    border-left: 5px solid #065f46 !important;
    background-color: #f0fdf4 !important;
    border-radius: 8px !important;
    padding: 16px !important;
    margin-top: 14px !important;
    margin-bottom: 4px !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08) !important;
    position: relative;
    z-index: 2;
    transition: all 0.2s ease;
}

/* Ocultar metadatos técnicos redundantes ("Empaque: Caja Principal") en la caja */
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box .wc-block-components-product-details {
    display: none !important;
}

/* Asegurar que la papelera de la caja principal esté visible, accesible y con cursor activo */
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box .wc-block-cart-item__remove-link,
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box [class*="remove-link"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box [class*="remove-button"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box button[aria-label*="eliminar"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box button[aria-label*="Eliminar"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box button[aria-label*="remove"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box button[aria-label*="Remove"],
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box a.remove {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    width: auto !important;
    height: auto !important;
}

/* Asegurar que el precio total de la caja sea visible */
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box .wc-block-cart-item__total,
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-box .wc-block-components-formatted-money-amount {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ocultar completamente los alfajores hijos en el Carrito y Checkout para que el combo figure como 1 solo ítem */
.wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-child,
.wc-block-cart-items tr.wc-block-cart-items__row.batllie-is-combo-child,
.wc-block-cart-item.batllie-is-combo-child,
.wc-block-components-order-summary-item.batllie-is-combo-child {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    border: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   3. Resumen de Sabores dentro de la Tarjeta de la Caja Principal
   ========================================================================== */
.batllie-box-flavors-summary {
    margin-top: 10px !important;
    padding: 9px 12px !important;
    background: #ffffff !important;
    border: 1px solid #bbf7d0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.06) !important;
    display: block !important;
    clear: both !important;
}

.batllie-box-flavors-title {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #14532d !important;
    margin-bottom: 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

.batllie-flavors-icon {
    font-size: 13px !important;
}

.batllie-box-flavors-pills {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
}

.batllie-flavor-pill {
    display: inline-flex !important;
    align-items: center !important;
    background: #f0fdf4 !important;
    border: 1px solid #86efac !important;
    color: #166534 !important;
    border-radius: 6px !important;
    padding: 3px 8px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
}

.batllie-flavor-pill strong {
    color: #15803d !important;
    margin-right: 4px !important;
    font-weight: 700 !important;
}


/* ==========================================================================
   4. Adaptación Responsiva (Móvil)
   ========================================================================== */

@media (max-width: 600px) {
    .wc-block-cart-items .wc-block-cart-items__row.batllie-is-combo-child {
        margin-left: 12px !important;
        width: calc(100% - 12px) !important;
        padding: 10px 12px !important;
    }
}

/* Efecto al eliminar una caja/combo completo */
.batllie-combo-delete-active {
    opacity: 0.4 !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease;
}

/* ==========================================================================
   5. Modal y Alerta de Reemplazo Rápido de Sabores Agotados (Alternativa A)
   ========================================================================== */

/* Alerta destacada en encabezado del carrito / checkout */
.batllie-combo-replacement-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fffbeb;
    border: 1.5px solid #f59e0b;
    border-left: 5px solid #d97706;
    border-radius: 12px;
    padding: 14px 18px;
    margin: 16px 0 22px 0;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.08);
    animation: batllieFadeIn 0.3s ease;
}

.batllie-replacement-alert-icon {
    font-size: 26px;
    flex-shrink: 0;
    line-height: 1;
}

.batllie-replacement-alert-content {
    flex-grow: 1;
}

.batllie-replacement-alert-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #92400e;
    line-height: 1.35;
    margin-bottom: 2px;
}

.batllie-replacement-alert-title strong {
    color: #78350f;
    font-weight: 800;
}

.batllie-replacement-alert-sub {
    font-size: 13px;
    color: #b45309;
    line-height: 1.4;
}

.batllie-replacement-alert-action-btn {
    background: #10b981;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.15s ease;
}

.batllie-replacement-alert-action-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Modal Backdrop */
.batllie-combo-replacement-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    animation: batllieFadeIn 0.25s ease;
}

/* Modal Dialog */
.batllie-combo-replacement-modal {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: #1e293b;
    color: #f8fafc;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65);
    padding: 24px;
    box-sizing: border-box;
    animation: batllieScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.batllie-replacement-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #94a3b8;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.batllie-replacement-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    transform: scale(1.08);
}

.batllie-replacement-modal-head {
    margin-bottom: 16px;
}

.batllie-replacement-head-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 6px;
}

.batllie-replacement-count-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.batllie-replacement-modal-title {
    font-size: 19px;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 12px 0;
    line-height: 1.3;
}

.batllie-replacement-depleted-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.28);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.batllie-depleted-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(239, 68, 68, 0.2);
    filter: grayscale(40%);
    flex-shrink: 0;
}

.batllie-depleted-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.batllie-depleted-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fca5a5;
    font-weight: 700;
}

.batllie-depleted-name {
    font-size: 14.5px;
    color: #ffffff;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batllie-depleted-qty {
    font-size: 12px;
    color: #fca5a5;
    font-weight: 500;
}

.batllie-replacement-instruction {
    font-size: 13.5px;
    color: #cbd5e1;
    line-height: 1.45;
    margin: 0;
}

/* Grid de opciones */
.batllie-replacement-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 18px;
}

.batllie-replacement-grid::-webkit-scrollbar {
    width: 4px;
}

.batllie-replacement-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
}

.batllie-replacement-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}

.batllie-replacement-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.batllie-replacement-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: #10b981;
    transform: translateY(-1px);
}

.batllie-replacement-thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.batllie-replacement-card-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.batllie-replacement-card-name {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.batllie-replacement-card-stock {
    font-size: 11px;
    color: #10b981;
    font-weight: 600;
    margin-top: 2px;
}

.batllie-replacement-select-btn {
    background: #10b981;
    color: #ffffff !important;
    border: none;
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.batllie-replacement-select-btn:hover {
    background: #059669;
}

.batllie-replacement-select-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.batllie-replacement-no-stock {
    text-align: center;
    padding: 16px 0;
    color: #94a3b8;
    font-size: 13px;
}

.batllie-replacement-modal-foot {
    display: flex;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 14px;
    margin-top: 4px;
}

.batllie-replacement-remove-combo-btn {
    background: transparent;
    color: #94a3b8;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.batllie-replacement-remove-combo-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

@keyframes batllieFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes batllieScaleUp {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 500px) {
    .batllie-combo-replacement-alert {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .batllie-replacement-alert-action-btn {
        width: 100%;
        text-align: center;
    }
    .batllie-replacement-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   6. Badge de Descuento en Medios de Pago (Checkout)
   ========================================================================== */

/* Asegurar que las opciones de pago en WooCommerce Blocks y clásico se mantengan alineadas a la izquierda */
.wc-block-checkout label,
.wc-block-components-radio-control label,
.wc-block-components-radio-control__option,
.wc-block-components-radio-control__option-layout,
.wc-block-components-radio-control__label-group,
.wc-block-components-radio-control__label {
    margin: 0 !important;
    text-align: left !important;
}

/* Fila del título de la opción de pago: flexbox horizontal que distribuye el texto a la izquierda y el badge a la derecha */
.wc-block-components-radio-control__label-group {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.wc-block-components-radio-control__label {
    display: inline-block !important;
    text-align: left !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Checkout clásico WooCommerce */
.woocommerce-checkout .wc_payment_methods label,
.woocommerce-checkout li.wc_payment_method label {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    text-align: left !important;
}

/* Badge de porcentaje con signo negativo en verde a la derecha del todo */
.batllie-payment-discount-badge {
    margin-left: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #15803d !important; /* Verde elegante */
    background: #ecfdf5 !important; /* Fondo verde menta suave */
    border: 1px solid #86efac !important; /* Borde verde claro */
    padding: 3px 9px !important;
    border-radius: 6px !important;
    font-size: 13.5px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    letter-spacing: -0.02em !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    text-transform: none !important;
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.08) !important;
}
