/* =============================================================================
   MINI CART - Sistema de cupones
   ============================================================================= */

/* Ocultar formulario si cupón no acumulable */
.b2c-hide-coupon-form {
    display: none;
}

/* =============================================================================
   SUBTOTAL WRAPPER
   ============================================================================= */
.woocommerce-mini-cart__total.total {
    margin-bottom: 20px !important;
    width: 100%;
}

/* Línea de subtotal */
.b2c-subtotal-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.b2c-subtotal-line .original-price {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Divisor */
.b2c-divider {
    display: block;
    width: 100%;
    height: 1px;
    background: var(--e-global-color-e91c093);
    margin: 10px 0;
}

/* Nueva línea de precio con descuento */
.b2c-price-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 12px;
}

.b2c-price-line .discounted-price {
    font-size: 25px;
    font-weight: 700;
    color: var(--e-global-color-secondary) !important;
    line-height: 1.2;
}

/* Sobrescribir estilos internos de WooCommerce */
.b2c-price-line .discounted-price .woocommerce-Price-amount,
.b2c-price-line .discounted-price .amount,
.b2c-price-line .discounted-price bdi,
.b2c-price-line .discounted-price * {
    color: var(--e-global-color-secondary) !important;
}

/* Contenedor cupón inline */
.b2c-coupon-wrapper {
    width: auto;
    max-width: 200px;
    display: flex;
    flex-direction: column;
}

.coupon-tag-inline {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 6px 12px;
    background: var(--e-global-color-primary);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
    text-align: center;
    gap: 8px;
}

.coupon-tag-inline span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

button.mini-cart-remove-coupon-inline {
    padding: 3px !important;
}
.mini-cart-remove-coupon-inline {
    background: none;
    border: none;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    padding: 3px;    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    flex-grow: 0;
    border-radius: 50%;
    transition: all 0.2s;
}

.mini-cart-remove-coupon-inline:hover {
    background: #fff;
    color: #000;
    
    
}

/* Restricciones del cupón */
.b2c-coupon-restrictions {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 0;
    font-size: 10px;
    color: #666;
    line-height: 1.6;
}

.b2c-coupon-rule {
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 4px;
}

.b2c-coupon-rule b {
    font-size: 10px;
    font-weight: 700;
    color: #333;
    margin-right: 3px;
}

/* =============================================================================
   FORMULARIO DE CUPÓN
   ============================================================================= */

/* Wrapper del formulario */
.b2c-coupon-form-wrapper {
    display: block;
    margin-top: 12px;
    width: 100%;
}

.b2c-coupon-form-inner {
    display: flex;
    gap: 8px;
    width: 100%;
}

/* Input wrapper con position relative para mensajes */
.b2c-input-wrapper {
    flex: 1;
    position: relative;
}

#mini_cart_coupon_code {
    width: 100%;
    padding: 15px 20px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: border-color 0.3s;
}

#mini_cart_coupon_code:focus {
    outline: none;
    border-color: var(--e-global-color-primary);
}

#mini_cart_apply_coupon {
    padding: 15px 20px;
    background: var(--e-global-color-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
        transition: background 0.3s;
}

#mini_cart_apply_coupon:hover {
    opacity: 0.9;
}

#mini_cart_apply_coupon {
    min-width: 100px;
    height: 48px;
}

#mini_cart_apply_coupon.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

#mini_cart_apply_coupon.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mensajes de error/éxito sobre el input */
.mini-cart-coupon-messages {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    transition: opacity 0.2s;
}

.mini-cart-coupon-messages.success,
.mini-cart-coupon-messages.error {
    display: flex;
}

.mini-cart-coupon-messages.success {
    background: rgba(16, 185, 129, 0.95);
    color: white;
}

.mini-cart-coupon-messages.error {
    background: rgba(239, 68, 68, 0.95);
    color: white;
}

    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* =============================================================================
   HEADER CART TOTAL
   ============================================================================= */
.jet-blocks-cart__total-val {
    opacity: 1;
}

/* =============================================================================
   CUPONES APLICADOS (LEGACY - Oculto)
   ============================================================================= */
.mini-cart-applied-coupons {
    display: none !important;
}

.mini-cart-coupon-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    border-radius: 50px;
    font-size: 13px;
}

.mini-cart-coupon-tag:last-child {
    margin-bottom: 0;
}

.mini-cart-coupon-tag .coupon-code {
    font-weight: 600;
    line-height: 1.2;
    color: #2e7d32;
    letter-spacing: 0.5px;
}

.mini-cart-remove-coupon {
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 3px !important;    padding: 0 5px;
    transition: color 0.2s;
    line-height: 1;
}

.mini-cart-remove-coupon:hover {
    color: #d32f2f;
}

.mini-cart-remove-coupon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mini-cart-remove-coupon-inline.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
    color: transparent;
}

.mini-cart-remove-coupon-inline.loading::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    top: 50%;
    left: 50%;
    margin-left: -5px;
    margin-top: -5px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Animación de actualización de precio */
.woocommerce-mini-cart__total.price-updated {
    animation: priceUpdate 0.8s ease;
}

@keyframes priceUpdate {
    0% { background: transparent; }
    50% { background: rgba(76, 175, 80, 0.1); }
    100% { background: transparent; }
}

/* Estilos para precio tachado y descuento */
.woocommerce-mini-cart__total .original-price {
    text-decoration: line-through;
    opacity: 0.6;
    margin-right: 8px;
}

/* Responsive */
@media (max-width: 480px) {
    .b2c-coupon-form-inner {
        flex-direction: column;
    }
    
    #mini_cart_apply_coupon {
        width: 100%;
    }
    
    .b2c-coupon-wrapper {
        width: 100%;
    }
}
