/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

/* === ESTRUCTURA GENERAL === */
.cartkubo-custom-cart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Montserrat', sans-serif;
    width: 100%;
}

/* === ESTADOS DE CARGA === */
.cartkubo-custom-cart.cartkubo-clearing {
    opacity: 0.6;
    pointer-events: none;
}

.cartkubo-cart-card.cartkubo-updating {
    opacity: 0.7;
    transform: scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.cartkubo-cart-card.cartkubo-removing {
    opacity: 0.5;
    transform: scale(0.95);
    transition: all 0.2s ease;
}

/* === EFECTOS VISUALES PARA BOTONES RÁPIDOS === */
.cartkubo-qty-input button.cartkubo-clicked {
    transform: scale(0.95) !important;
    background-color: rgba(250, 176, 0, 0.1) !important;
    transition: all 0.1s ease !important;
}

.cartkubo-qty-input button.cartkubo-qty-plus.cartkubo-clicked {
    border-color: #fab000 !important;
    box-shadow: 0 0 0 2px rgba(250, 176, 0, 0.2) !important;
}

.cartkubo-qty-input button.cartkubo-qty-minus.cartkubo-clicked {
    border-color: #fa010a !important;
    box-shadow: 0 0 0 2px rgba(250, 1, 10, 0.2) !important;
}

/* Animación de actualización rápida */
.cartkubo-cart-card.cartkubo-fast-update {
    animation: cartkubo-fast-update 0.3s ease-out;
}

@keyframes cartkubo-fast-update {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* === MODO SPAM - INDICADORES VISUALES === */
.cartkubo-cart-card.cartkubo-spam-mode {
    border-color: #fab000 !important;
    box-shadow: 0 0 0 2px rgba(250, 176, 0, 0.3) !important;
    animation: cartkubo-spam-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes cartkubo-spam-pulse {
    0% { box-shadow: 0 0 0 2px rgba(250, 176, 0, 0.3); }
    100% { box-shadow: 0 0 0 4px rgba(250, 176, 0, 0.6); }
}

/* Botones en modo spam */
.cartkubo-qty-input button.cartkubo-spam-active {
    transform: scale(1.05) !important;
    border-width: 3px !important;
    animation: cartkubo-button-spam 0.2s ease-in-out infinite alternate;
}

@keyframes cartkubo-button-spam {
    0% { transform: scale(1.05); }
    100% { transform: scale(1.08); }
}

/* Indicador de modo spam en el input */
.cartkubo-qty-input-wrapper.cartkubo-spam-mode input {
    background: linear-gradient(45deg, #fff, #f8f9fa) !important;
    border-color: #fab000 !important;
    font-weight: 700 !important;
}

.cartkubo-qty-input button.cartkubo-disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    background-color: #f5f5f5 !important;
    border-color: #ddd !important;
    color: #999 !important;
    transform: none !important;
    box-shadow: none !important;
}

.cartkubo-qty-input button.cartkubo-disabled:hover,
.cartkubo-qty-input button.cartkubo-disabled:focus,
.cartkubo-qty-input button.cartkubo-disabled:active {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
    border-color: #ddd !important;
    color: #999 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* === DIVISORES HORIZONTALES === */
.cartkubo-cart-divider {
    width: 100%;
    height: 2px;
    background-color: #888;
    margin-top: 5px;
    margin-bottom: 14px;
    border: none;
}

/* === HEADER DEL CARRITO === */
.cartkubo-cart-header-row {
    display: grid;
    grid-template-columns: 160px 1fr 190px 100px 50px;
    width: 100%;
    align-items: center;
    font-weight: 700;
    font-size: 1rem;
    color: #202020;
    min-height: 48px;
    margin-bottom: 0;
    padding-left: 0;
}

.cartkubo-header-col {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 48px;
    padding: 8px 16px;
    background: transparent;
    font-size: 1rem;
    width: 100%;
    grid-column: auto;
}

/* Ajuste para que el header coincida con las columnas del card */
.cartkubo-header-col.cartkubo-header-img { grid-column: 1; }
.cartkubo-header-col.cartkubo-header-product { grid-column: 2; }
.cartkubo-header-col.cartkubo-header-qty { grid-column: 3; }
.cartkubo-header-col.cartkubo-header-total { grid-column: 4; }
.cartkubo-header-col.cartkubo-header-actions { grid-column: 5; }

.cartkubo-cart-header-hr {
    width: 100%;
    height: 1px;
    background: #ccc;
    margin-bottom: 8px;
}

/* === CARD DE PRODUCTO === */
.cartkubo-cart-card {
    display: grid;
    grid-template-columns: 160px 1fr 190px 100px 50px;
    align-items: center;
    border: 2px solid #888888;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #fff;
    padding: 0;
    color: #202020;
    font-weight: 500;
    font-size: 1rem;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    margin-bottom: 12px;
    height: 120px;
    width: 100%;
}

/* Subtotal con descuento - 2 líneas verticales en pantallas >1350px */
.cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-discount-single-line {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    flex-wrap: nowrap !important;
}

.cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original,
.cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    margin: 0 !important;
}

.cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original {
    font-size: 0.75rem !important;
    order: 2 !important;
}

.cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
    font-size: 1rem !important;
    font-weight: 700 !important;
    order: 1 !important;
}

/* Layout para pantallas menores a 1350px - 4 columnas */
@media (max-width: 1350px) {
    .cartkubo-cart-card {
        grid-template-columns: 132px 1fr 189px 49px !important;
        grid-template-rows: 1fr !important;
        gap: 12px !important;
        padding: 12px !important;
        height: auto;
        min-height: 100px !important;
    }
    .cartkubo-cart-col.cartkubo-cart-qty {
        margin-top: -28px !important;
    }
    .cartkubo-cart-col.cartkubo-cart-total {
        margin-top: 56px !important;
        width: 190px !important;
    }
    /* Columna 1: Imagen */
    .cartkubo-cart-col.cartkubo-cart-image {
        grid-column: 1 !important;
        grid-row: 1;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Columna 2: Título y Precio */
    .cartkubo-cart-col.cartkubo-cart-info {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
    }
    
    /* Columna 3: Cantidad y Subtotal */
    .cartkubo-cart-col.cartkubo-cart-qty {
        grid-column: 3;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 8px;
    }
    
    .cartkubo-cart-col.cartkubo-cart-total {
        grid-column: 3;
        grid-row: 1;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        margin-top: auto;
    }
    
    /* Columna 4: Botones de Acción */
    .cartkubo-cart-col.cartkubo-cart-actions {
        grid-column: 4;
        grid-row: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Subtotal con descuento - una línea horizontal en pantallas ≤1350px */
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-discount-single-line {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
    }
    
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original,
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
        display: inline-block !important;
        text-align: center !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }
    
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original {
        font-size: 0.75rem !important;
        order: 2 !important;
    }
    
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
        font-size: 1rem !important;
        font-weight: 700 !important;
        order: 1 !important;
    }
}

.cartkubo-cart-card:hover {
    transform: translateY(-1px);
    border-color: #fab000;
    box-shadow: 0 4px 12px rgba(250, 176, 0, 0.2);
}

/* === COLUMNA 1 - IMAGEN === */
.cartkubo-cart-col.cartkubo-cart-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 120px;
    padding: 0;
    margin: 0;
    margin-top: -24px;
}

.cartkubo-cart-col.cartkubo-cart-img img {
    width: 160px;
    height: 120px;
    object-fit: cover;
    border-radius: 0;
    padding: 0;
    margin: 0;
    display: block;
}

/* === COLUMNA 2 - INFORMACIÓN DEL PRODUCTO === */
.cartkubo-cart-col.cartkubo-cart-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    gap: 8px;
}

.cartkubo-cart-product-title {
    font-size: 1rem;
    font-weight: 500;
    color: #202020;
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
    /* Truncado a máximo 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.3em * 2); /* 2 líneas máximo */
}

.cartkubo-cart-product-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.cartkubo-cart-product-title {
    font-size: 1rem;
    font-weight: 400;
    color: #202020;
    margin-bottom: 2px;
    word-break: break-word;
    /* Truncado a máximo 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.3em * 2); /* 2 líneas máximo */
}
.cartkubo-cart-product-prices {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}
.cartkubo-cart-product-price-regular {
    font-size: 0.9em;
    color: #888;
}
.cartkubo-cart-product-price-discount {
    color: #202020;
    font-weight: 700;
    font-size: 1em;
}
.cartkubo-price-suffix {
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 3px;
}

/* === COLUMNA 3 - QUANTITY INPUT === */
.cartkubo-cart-col.cartkubo-cart-qty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    width: 190px;
    min-width: 190px;
    max-width: 190px;
    margin-top: 0px;
}
.cartkubo-qty-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}
.cartkubo-qty-input button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 2px solid #ddd;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
    transition: border 0.2s ease, opacity 0.3s ease;
    outline: none !important;
}
.cartkubo-qty-input button:focus,
.cartkubo-qty-input button:active,
.cartkubo-qty-input button:focus-visible {
    background: none !important;
    outline: none !important;
    box-shadow: none !important;
}
.cartkubo-qty-input button.cartkubo-qty-minus { color: #fa010a; border-color: #888888; }
.cartkubo-qty-input button.cartkubo-qty-plus { color: #fab000; border-color: #888888; }
.cartkubo-qty-input button.cartkubo-qty-minus:hover:not(.cartkubo-disabled),
.cartkubo-qty-input button.cartkubo-qty-minus:focus:not(.cartkubo-disabled) { border: 2px solid #fa010a; background: none !important; }
.cartkubo-qty-input button.cartkubo-qty-plus:hover:not(.cartkubo-disabled),
.cartkubo-qty-input button.cartkubo-qty-plus:focus:not(.cartkubo-disabled) { border: 2px solid #fab000; background: none !important; }
.cartkubo-qty-input button.cartkubo-qty-minus:active:not(.cartkubo-disabled) { border: 2px solid #fa010a; background: none !important; }
.cartkubo-qty-input button.cartkubo-qty-plus:active:not(.cartkubo-disabled) { border: 2px solid #fab000; background: none !important; }

.cartkubo-qty-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.cartkubo-qty-input-wrapper input {
    min-width: 90px;
    max-width: 90px;
    height: 40px;
    font-size: 1rem;
    text-align: right;
    padding: 0 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    appearance: textfield;
    flex: 0 1 auto;
}

/* === COLUMNA 5 - BOTONES SIEMPRE VISIBLES === */
.cartkubo-card-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    z-index: 1;
}
.cartkubo-card-actions a,
.cartkubo-card-actions button {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    text-align: center;
    line-height: 1;
    flex-shrink: 0;
}

/* Estilos para los iconos dentro de los botones */
.cartkubo-card-actions a img,
.cartkubo-card-actions button img {
    object-fit: contain !important;
    transition: all 0.2s ease;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
}

.cartkubo-card-actions a.cartkubo-dot-menu { 
    background-color: #fab000; 
    color: #ffffff; 
}

.cartkubo-card-actions button.cartkubo-close-x { 
    background-color: #e74c3c; 
    color: #ffffff; 
}

.cartkubo-card-actions a:hover,
.cartkubo-card-actions button:hover { 
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.cartkubo-card-actions a.cartkubo-dot-menu:hover {
    background-color: #e6a200;
}

.cartkubo-card-actions button.cartkubo-close-x:hover {
    background-color: #c0392b;
}

/* Efectos hover para los iconos */
.cartkubo-card-actions a:hover img,
.cartkubo-card-actions button:hover img {
    transform: scale(1.2);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* CSS ESPECÍFICO PARA FORZAR TAMAÑO DE IMÁGENES */
.cartkubo-card-actions .cartkubo-dot-menu img {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    object-fit: contain !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

.cartkubo-card-actions .cartkubo-close-x img {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    object-fit: contain !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
}

/* === BOTONES DE ABAJO === */
.cartkubo-cart-clear-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    width: 100%;
}

.cartkubo-cart-clear-btn,
.cartkubo-cart-shop-btn {
    background: none !important;
    border: none !important;
    font-size: 1rem;
    font-weight: 600 !important;
    cursor: pointer;
    text-decoration: underline !important;
    padding: 0;
    transition: color 0.15s ease, font-weight 0.15s ease, text-decoration 0.15s ease, transform 0.15s ease;
    box-shadow: none !important;
}

.cartkubo-cart-clear-btn {
    color: #888888 !important;
}

.cartkubo-cart-shop-btn {
    color: #888888 !important;
}

.cartkubo-cart-clear-btn:hover {
    color: #fa010a !important;
}

.cartkubo-cart-shop-btn:hover {
    color: #fab000 !important;
}

/* === CARD DE CARRITO VACÍO === */
.cartkubo-cart-card.cartkubo-cart-empty {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ccc;
    background: #fafafa;
    color: #888;
    font-size: 1.25rem;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0,0,0,0.04);
    padding: 32px 16px;
    transition: transform 0.2s ease;
}

.cartkubo-cart-card.cartkubo-cart-empty:hover {
    transform: scale(1);
}

.cartkubo-cart-empty-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.cartkubo-cart-empty-content img {
    margin-bottom: 16px;
}
.cartkubo-cart-empty-text {
    text-align: center;
    font-size: 1.25rem;
    color: #888;
    font-weight: 600;
}

/* === COLUMNA 4 - SUBTOTAL === */
.cartkubo-cart-col.cartkubo-cart-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0px;
    width: 108px;
    margin-top: 0px;
}

/* === INDICADOR DE CARGA PARA SUBTOTAL === */
.kubo-loading-indicator {
    color: #666;
    font-style: italic;
    font-size: 0.9rem;
    animation: kubo-pulse 1.5s ease-in-out infinite;
}

@keyframes kubo-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.cartkubo-item-total {
    font-weight: 700;
    font-size: 1rem;
    color: #202020;
    text-align: center;
}

.cartkubo-item-total-original {
    font-weight: 500;
    font-size: 0.75rem;
    color: #888;
    text-decoration: line-through;
    text-align: center;
}

.cartkubo-item-total-sale {
    font-weight: 700;
    font-size: 1rem;
    color: #e74c3c;
    text-align: center;
}

/* === ESTILOS PARA LOS SHORTCODES DE TOTALES === */

/* Subtotal - 1rem, peso 500, informativo */
body .cartkubo-subtotal-carrito,
body .woocommerce-subtotal-carrito,
body .kubo-subtotal {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
    color: #202020 !important;
    transition: all 0.2s ease !important;
}

/* Subtotal Header - 1rem, peso 500, informativo (precios finales con descuentos) */
body .cartkubo-subtotalheader,
body .woocommerce-subtotalheader,
body .kubo-subtotalheader {
    font-family: 'Montserrat', sans-serif !important;
    transition: all 0.2s ease !important;
}

/* Envío - 1rem, peso 500, mismo que subtotal */
body .cartkubo-envio-simple,
body .woocommerce-envio-simple,
body .kubo-envio {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
    color: #202020 !important;
    transition: all 0.2s ease !important;
}

/* Descuentos - 1rem, peso 500, color verde como highlight */
body .cartkubo-descuento-total,
body .woocommerce-descuento-total,
body .kubo-descuento {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
    color: #28a745 !important;
    transition: all 0.2s ease !important;
}

/* Total - 1.25rem, peso 700, foco visual principal */
body .cartkubo-total-carrito,
body .woocommerce-total-carrito,
body .kubo-total {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    color: #202020 !important;
    transition: all 0.2s ease !important;
}

/* === ESTILOS PARA SELECTOR DE MÉTODOS DE ENVÍO === */
.kubo-shipping-rates {
    font-family: 'Montserrat', sans-serif;
    margin: 10px 0;
}

.kubo-shipping-rate-option {
    display: flex !important;
    align-items: center !important;
    padding: 8px 12px !important;
    margin-bottom: 8px !important;
    border: 2px solid #ddd !important;
    border-radius: 6px !important;
    background: #fff !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.kubo-shipping-rate-option:hover {
    border-color: #fab000 !important;
    background: #fffbf0 !important;
}

.kubo-shipping-rate-option input[type="radio"] {
    margin-right: 10px !important;
    transform: scale(1.2) !important;
}

.kubo-shipping-rate-option input[type="radio"]:checked + span {
    font-weight: 700 !important;
    color: #fab000 !important;
}

.kubo-shipping-rate-option:has(input[type="radio"]:checked) {
    border-color: #fab000 !important;
    background: #fffbf0 !important;
}

.kubo-shipping-single {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 500 !important;
    color: #202020 !important;
}

/* === ANIMACIÓN PARA "CALCULANDO..." === */
@keyframes kubo-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* === BARRA DE ENVÍO GRATIS === */
/* Estilos base con especificidad adecuada */
.cartkubo-free-shipping-progress {
    width: 100%;
    background: #fab000; /* CAMBIADO: Fondo #fab000 en lugar de blanco */
    border: 0 8px 0 8px solid transparent;
    overflow: hidden;
    position: relative;
    height: 24px;
    margin: 8px 0;
    top: 0;
    left: 0;
    transform: none;
    box-sizing: border-box;
}

/* Mayor especificidad solo cuando sea necesario */
body .cartkubo-free-shipping-progress {
    width: 100% !important;
    height: 24px !important;
    margin: 8px 0 !important;
}

/* Estilos base para barra de progreso */
.cartkubo-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #fab000, #ffd700);
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(250, 176, 0, 0.3);
    animation: kubo-progress-pulse 2s ease-in-out infinite;
    border: 0 8px 0 8px solid transparent;
    position: relative;
    z-index: 1;
    float: left;
    margin: 0;
    padding: 0;
}

/* Mayor especificidad solo cuando sea necesario */
body .cartkubo-progress-bar {
    height: 100% !important;
    float: left !important;
}

/* Mayor especificidad para templates */
body .cartkubo-progress-text,
.cartkubo-progress-text {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #202020 !important;
    text-align: center !important;
    white-space: nowrap !important;
    z-index: 2 !important;
    font-family: 'Montserrat', sans-serif !important;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8) !important;
}

/* Mayor especificidad para templates */
body .cartkubo-free-shipping-achieved,
.cartkubo-free-shipping-achieved {
    background: #fab000 !important; /* CAMBIADO: Fondo #fab000 en lugar de blanco */
    border-top: 0px !important;
    border-bottom: 8px !important;
    border-left: 0px !important;
    border-right: 8px !important;
    text-align: center !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    margin: 12px 0 !important;
    font-family: 'Montserrat', sans-serif !important;
    position: relative !important;
    overflow: hidden !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cartkubo-free-shipping-achieved .cartkubo-success-bar {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    animation: kubo-expand-from-center 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    z-index: 1;
}

.cartkubo-free-shipping-achieved .cartkubo-success-text {
    position: relative;
    z-index: 2;
    color: #ffffff;
    opacity: 0;
    animation: kubo-text-fade-in 0.3s ease-out 0.8s forwards;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes kubo-expand-from-center {
    0% { 
        width: 0%;
        box-shadow: 0 0 0 rgba(40, 167, 69, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.6);
    }
    100% { 
        width: 100%;
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.4);
    }
}

@keyframes kubo-text-fade-in {
    0% { 
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    50% {
        transform: scale(1.05) translateY(-2px);
    }
    100% { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes kubo-progress-pulse {
    0% { 
        box-shadow: 0 0 10px rgba(250, 176, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(250, 176, 0, 0.5);
    }
    100% { 
        box-shadow: 0 0 10px rgba(250, 176, 0, 0.3);
    }
}

@keyframes kubo-text-bounce {
    0% { 
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
    100% { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes kubo-progress-shrink {
    0% { 
        width: 100%;
        background: linear-gradient(90deg, #28a745, #20c997);
    }
    100% { 
        background: linear-gradient(90deg, #fab000, #ffd700);
    }
}

/* Compatibilidad con selectores antiguos */
.cartkubo-free-shipping-bar,
.cartkubo-progress {
    width: 100%;
}

/* PREVENIR que la barra se mueva al actualizarse */
#barra-envio-gratis-simple {
    position: relative !important;
    border-radius: 0px 0px 8px 8px !important;
    margin: 12px 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    transition: none !important;
    /* DIMENSIONES FIJAS - CORREGIDO */
    width: 100% !important;
    height: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    overflow: visible !important;
    display: block !important;
    text-align: left !important;
    box-sizing: border-box !important;
}

/* Forzar que el contenedor no se mueva */
.cartkubo-free-shipping-progress {
    position: relative !important;
    margin: 0 !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    transition: none !important;
    /* DIMENSIONES FIJAS - CORREGIDO */
    width: 100% !important;
    height: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    overflow: visible !important;
    /* CONTENIDO FIJO - NO CENTRAR */
    display: block !important;
    text-align: left !important;
    box-sizing: border-box !important;
}

/* Forzar que el texto no afecte el tamaño */
.cartkubo-progress-text {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* FORZAR que la barra de progreso empiece desde la izquierda */
#barra-envio-gratis-simple .cartkubo-progress-bar {
    float: left !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0px 0px 8px 8px !important;
}

/* Asegurar que el contenedor no tenga centrado */
#barra-envio-gratis-simple {
    text-align: left !important;
    display: block !important;
}

/* CORRECCIÓN ADICIONAL: Asegurar que la barra de progreso se vea completa */
#barra-envio-gratis-simple .cartkubo-free-shipping-progress {
    height: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    overflow: hidden !important;
    position: relative !important;
    display: block !important;
    box-sizing: border-box !important;
}

#barra-envio-gratis-simple .cartkubo-progress-bar {
    height: 100% !important;
    min-height: 24px !important;
    max-height: 24px !important;
    position: relative !important;
    display: block !important;
    box-sizing: border-box !important;
}

.cartkubo-free-shipping-bar .cartkubo-progress {
    width: 100%;
    background: #f0f0f0;
    border-top: 0px;
    border-bottom: 8px;
    border-left: 0px;
    border-right: 8px;
    overflow: hidden;
    position: relative;
    height: 24px;
    margin: 12px 0;
    box-sizing: border-box;
}

/* === ESTILOS ESPECÍFICOS PARA TEMPLATES === */
/* Forzar estilos en templates que puedan tener conflictos - SIN all: unset */
body .cartkubo-free-shipping-progress,
body .cartkubo-free-shipping-achieved,
body .cartkubo-progress-bar,
body .cartkubo-progress-text {
    display: block !important;
    position: relative !important;
    box-sizing: border-box !important;
}

/* Reset específico para templates */
body .cartkubo-free-shipping-progress {
    width: 100% !important;
    height: 24px !important;
    background: #fab000 !important; /* CAMBIADO: Fondo #fab000 en lugar de blanco */
    border-radius: 0px 0px 8px 8px !important;
    overflow: hidden !important;
    margin: 8px 0 !important;
}

body .cartkubo-progress-bar {
    height: 100% !important;
    background: linear-gradient(90deg, #fab000, #ffd700) !important;
    transition: width 0.4s ease !important;
    float: left !important;
}

body .cartkubo-progress-text {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #202020 !important;
    text-align: center !important;
    white-space: nowrap !important;
    z-index: 2 !important;
    font-family: 'Montserrat', sans-serif !important;
}

body .cartkubo-free-shipping-achieved {
    width: 100% !important;
    height: 24px !important;
    background: #fab000 !important; /* CAMBIADO: Fondo #fab000 en lugar de blanco */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    overflow: hidden !important;
    margin: 12px 0 !important;
}

/* === OPTIMIZACIONES DE VELOCIDAD === */
.cartkubo-cart-card {
    will-change: transform, opacity; /* Optimización para animaciones */
}

.cartkubo-qty-input button {
    will-change: transform; /* Optimización para botones */
}

/* Indicador de carga para shortcodes globales */
.cartkubo-subtotalheader,
.woocommerce-subtotalheader,
.kubo-subtotalheader,
.cartkubo-items-count,
.kubo-items-count,
#barra-envio-gratis-simple,
.cartkubo-free-shipping-progress,
.cartkubo-free-shipping-bar,
.cartkubo-progress,
.kubo-free-shipping-bar {
    transition: opacity 0.3s ease;
}

/* Estado de carga */
.cartkubo-subtotalheader.loading,
.woocommerce-subtotalheader.loading,
.kubo-subtotalheader.loading,
.cartkubo-items-count.loading,
.kubo-items-count.loading,
#barra-envio-gratis-simple.loading,
.cartkubo-free-shipping-progress.loading,
.cartkubo-free-shipping-bar.loading,
.cartkubo-progress.loading,
.kubo-free-shipping-bar.loading {
    opacity: 0.3;
    position: relative;
}

/* Spinner de carga */
.cartkubo-subtotalheader.loading::after,
.woocommerce-subtotalheader.loading::after,
.kubo-subtotalheader.loading::after,
.cartkubo-items-count.loading::after,
.kubo-items-count.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: kubo-spin 1s linear infinite;
}

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

/* === OCULTAR SHORTCODES GLOBALES HASTA QUE SE ACTUALICEN === */
/* CRÍTICO: Ocultar los 3 shortcodes específicos por defecto para evitar mostrar datos incorrectos */
.cartkubo-subtotalheader, 
.woocommerce-subtotalheader, 
.kubo-subtotalheader,
.cartkubo-items-count, 
.kubo-items-count {
    opacity: 0 !important; /* OCULTAR hasta actualizar */
    transition: opacity 0.2s ease-in-out !important; /* Transición MÁS RÁPIDA */
    will-change: opacity !important; /* Optimización para animaciones */
}

/* BARRA DE ENVÍO GRATIS - TRACK CON FONDO FIJO (#eaeaea) Y SIN OPACIDAD */
#barra-envio-gratis-simple, 
.cartkubo-free-shipping-progress, 
.cartkubo-free-shipping-bar {
    background-color: #eaeaea !important; /* Track neutro */
    opacity: 1 !important; /* Evitar capa translúcida */
    transition: all 0.1s ease-in-out !important; /* Transición rápida */
    will-change: auto !important;
}

/* MOSTRAR cuando estén actualizados */
.cartkubo-subtotalheader.updated, 
.woocommerce-subtotalheader.updated, 
.kubo-subtotalheader.updated,
.cartkubo-items-count.updated, 
.kubo-items-count.updated {
    opacity: 1 !important; /* MOSTRAR cuando estén actualizados */
}

/* BARRA DE ENVÍO GRATIS - ESTADO ACTUALIZADO (mantener track gris, solo el fill cambia) */
#barra-envio-gratis-simple.updated, 
.cartkubo-free-shipping-progress.updated, 
.cartkubo-free-shipping-bar.updated {
    background-color: #eaeaea !important; /* Mantener track gris al estar actualizado */
    opacity: 1 !important;
}

/* FILL DE PROGRESO SIEMPRE VISIBLE Y OPACO */
.cartkubo-progress-bar,
.cartkubo-success-bar {
    background-color: #fab000 !important; /* Color del progreso */
    opacity: 1 !important; /* Sin transparencia en el fill */
}

/* Texto de la barra completamente opaco */
.cartkubo-progress-text,
.cartkubo-success-text {
    opacity: 1 !important;
    text-align: center !important; /* centrar texto */
    width: 100%;
}

/* CART-SPECIFIC OVERRIDES: evitar desaparición si se pierde la clase en fragments */
body.woocommerce-cart .cartkubo-subtotalheader,
body.woocommerce-cart .woocommerce-subtotalheader,
body.woocommerce-cart .kubo-subtotalheader,
body.woocommerce-cart .cartkubo-items-count,
body.woocommerce-cart .kubo-items-count,
body.woocommerce-cart [data-shortcode="subtotalheader"],
body.woocommerce-cart [data-shortcode="items_count"] {
    opacity: 1 !important;
}

/* Asegurar visibilidad y evitar colapsos de inline elements */
[data-shortcode],
.cartkubo-subtotalheader, .woocommerce-subtotalheader, .kubo-subtotalheader,
.cartkubo-items-count, .kubo-items-count {
    display: inline-block;
    min-width: 1ch;
    vertical-align: middle;
}

/* Alineación y tamaño consistentes de la barra de envío gratis */
#barra-envio-gratis-simple,
.cartkubo-free-shipping-progress,
.cartkubo-free-shipping-bar {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cartkubo-progress-bar,
.cartkubo-success-bar {
    height: 8px;
    min-height: 8px;
    border-radius: 4px;
}

/* === PREVENIR GLITCHEO DE LA BARRA DE ENVÍO GRATIS === */
/* Estabilizar la barra para evitar cambios de color repetitivos */
.cartkubo-free-shipping-progress,
.cartkubo-free-shipping-achieved,
#barra-envio-gratis-simple {
    transition: all 0.1s ease-in-out !important; /* TRANSICIÓN MÁS RÁPIDA */
    will-change: auto !important; /* Evitar cambios de layout */
}

/* Prevenir cambios de color repetitivos */
.cartkubo-progress-bar {
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important; /* TRANSICIÓN MÁS RÁPIDA */
    will-change: width !important; /* Solo animar el ancho */
} 
 
/* === LAYOUT PARA CELULAR (≤768px) === */
@media (max-width: 768px) {
    /* Grid principal: 3 columnas, 3 filas */
    .cartkubo-cart-card {
        grid-template-columns: 100px 1fr 60px !important;
        grid-template-rows: auto auto auto !important;
        gap: 8px !important;
        padding: 12px !important;
        height: auto !important;
        min-height: 120px !important;
    }

    /* Columna 1: fila 1 = imagen, fila 2 = cantidad */
    .cartkubo-cart-col.cartkubo-cart-image,
    .cartkubo-cart-col.cartkubo-cart-img {
        grid-column: 1 !important;
        grid-row: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
    }

    .cartkubo-cart-col.cartkubo-cart-image img,
    .cartkubo-cart-col.cartkubo-cart-img img {
        object-fit: cover !important;
        border-radius: 8px !important;
    }

    .cartkubo-cart-col.cartkubo-cart-qty {
        grid-column: 1 !important;
        grid-row: 2 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-top: 0 !important;
        padding: 0 !important;
    }

    .cartkubo-cart-col.cartkubo-cart-qty .cartkubo-qty-input {
        width: 88px !important;
        margin-top: 0 !important;
    }

    .cartkubo-cart-col.cartkubo-cart-qty .cartkubo-qty-input input {
        width: 64px !important;
        font-size: 0.9rem !important;
        padding: 6px !important;
    }

    /* Columna 2: fila 1 = título, fila 2 = precios, fila 3 = subtotal */
    .cartkubo-cart-col.cartkubo-cart-info {
        grid-column: 2 !important;
        grid-row: 1 / 3 !important; /* ocupa filas 1 y 2 */
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        gap: 4px !important;
        padding: 0 !important;
    }

    .cartkubo-cart-col.cartkubo-cart-info .cartkubo-cart-product-title {
        font-size: 0.95rem !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
        max-height: calc(1.2em * 2) !important;
    }

    /* Fila 2: precios del producto (regular + descuento) */
    .cartkubo-cart-col.cartkubo-cart-info .cartkubo-cart-product-prices,
    .cartkubo-cart-col.cartkubo-cart-info .cartkubo-cart-product-price {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
    }

    /* Fila 3: subtotal (columna 2) */
    .cartkubo-cart-col.cartkubo-cart-total {
        grid-column: 2 !important;
        grid-row: 3 !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        margin-top: 0 !important;
        width: auto !important;
        padding: 0 !important;
    }

    /* En móvil mantenemos una línea horizontal para descuentos */
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-discount-single-line {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
    }

    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original,
    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
        display: inline-block !important;
        text-align: left !important;
        margin: 0 !important;
        white-space: nowrap !important;
        font-size: 0.9rem !important;
    }

    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-original {
        font-size: 0.8rem !important;
        order: 2 !important;
    }

    .cartkubo-cart-col.cartkubo-cart-total .cartkubo-item-total-sale {
        font-size: 1rem !important;
        font-weight: 600 !important;
        order: 1 !important;
    }

    /* Columna 3: botones de acción (ocupa todas las filas) */
    .cartkubo-cart-col.cartkubo-cart-actions {
        grid-column: 3 !important;
        grid-row: 1 / 4 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 8px !important;
    }

    .cartkubo-cart-col.cartkubo-cart-actions .cartkubo-card-actions {
        width: 50px !important;
        min-width: 50px !important;
        max-width: 50px !important;
        padding: 4px !important;
    }

    .cartkubo-cart-col.cartkubo-cart-actions .cartkubo-card-actions a,
    .cartkubo-cart-col.cartkubo-cart-actions .cartkubo-card-actions button {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.7rem !important;
    }
}

@media (max-width: 768px) {
    .cartkubo-cart-col.cartkubo-cart-img {
        width: 160px;
        height: 72px;
        padding: 0;
        margin: 0;
        margin-top: -50px;
    }
    .cartkubo-qty-input-wrapper input {
        min-width: 60px;
        max-width: 60px;
    }
    .cartkubo-cart-col.cartkubo-cart-qty {
        min-width: 156px !important;
        max-width: 156px !important;
        margin-bottom: -34px;
        padding: 8px;
    }
    .cartkubo-qty-input {
        gap: 0px;
    }
    input[type=date], input[type=email], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=url], select, textarea {
        border: 1.5px solid #888888;
        border-top-right-radius: 0px;
        border-bottom-right-radius: 0px;
        border-top-left-radius: 0px;
        border-bottom-left-radius: 0px;
        transition: all .2s;
    }
    .cartkubo-qty-input button.cartkubo-qty-plus {
        border-top-right-radius: 8px;
        border-bottom-right-radius: 8px;
        border-top-left-radius: 0px;
        border-bottom-left-radius: 0px;
    }
    .cartkubo-qty-input button.cartkubo-qty-minus {
        border-top-right-radius: 0px;
        border-bottom-right-radius: 0px;
        border-top-left-radius: 8px;
        border-bottom-left-radius: 8px;
    }
    .cartkubo-cart-card {
        grid-template-columns: 150px 1fr 48px !important;
        grid-template-rows: auto auto auto !important;
        gap: 8px !important;
        height: 156px !important;

    }
    .cartkubo-cart-col.cartkubo-cart-info {
        margin-top: -18px;
    }
    .cartkubo-cart-col.cartkubo-cart-total {
        margin-top: -28px !important;
    }
    .cartkubo-card-actions {
        gap: 16px;
        margin-bottom: -62px;
        margin-top: 13px;
    }
    .cartkubo-custom-cart {
        gap: 4px;
    }
    .cartkubo-cart-col.cartkubo-cart-image img, .cartkubo-cart-col.cartkubo-cart-img img {
        width: 140px !important;
        height: 108px !important;
    }
}
