/*
 * LEO Commerce UI v0.5.11.296 — Ordem subtotal, entrega, desconto e total (visual-only).
 * Mantém o <tr class="cart-discount"> nativo e o link Woo de remoção.
 * NÃO troca o total, frete, regras, conteúdo ou mecanismos de cupons.
 * Escopo: exclusivamente carrinho clássico Woo / carrinho Blocksy.
 */

/* Linha financeira, sem card independente acima da entrega. */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    width: 100% !important;
    margin: 0 !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th,
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border-top: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    box-sizing: border-box !important;
    line-height: 1.35 !important;
}

/* Oculta apenas a legenda visual nativa 'Cupom: codigo', preservando-a
   no DOM, e a substitui pela legenda amigável 'Desconto'. */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th {
    font-size: 0 !important;
    text-align: left !important;
    color: #4b5563 !important;
    font-weight: 600 !important;
}
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th::before {
    content: "Desconto" !important;
    display: inline-block !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    color: #4b5563 !important;
}

body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
    text-align: right !important;
    color: #178653 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
}
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td::before {
    content: none !important;
    display: none !important;
}
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td .amount,
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td .woocommerce-Price-amount,
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td .woocommerce-Price-amount bdi {
    color: #178653 !important;
    font-weight: 700 !important;
    font-size: inherit !important;
}

/* Ação permanece funcional e é discreta, sem competir com o valor. */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon {
    display: block !important;
    width: max-content !important;
    max-width: 100% !important;
    margin: 2px 0 0 auto !important;
    padding: 0 !important;
    color: #6b7280 !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    font-weight: 500 !important;
    text-align: right !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
}
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon:hover,
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon:focus-visible {
    color: #123b82 !important;
}

/* Desktop: 1=Envio (card), 2=Subtotal, 3=Entrega, 4=Desconto, 5=Total. */
@media (min-width: 1025px) {
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
        order: 4 !important;
        padding: 0 16px 13px !important;
        border-left: 1px solid #dde1e5 !important;
        border-right: 1px solid #dde1e5 !important;
        border-radius: 0 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th,
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
        padding: 0 0 13px !important;
        border-bottom: 1px solid #ededed !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.leo-shipping-cost-row {
        order: 3 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.order-total {
        order: 5 !important;
    }
}

/* Celular: mantém o acordeão de cupom e a pilha já homologada; frete antes do desconto. */
@media (max-width: 767px) {
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
        order: 4 !important;
        padding: 0 15px 12px !important;
        border-left: 1px solid #dde1e5 !important;
        border-right: 1px solid #dde1e5 !important;
        border-radius: 0 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th,
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
        padding: 8px 0 !important;
        border-bottom: 1px solid #ededed !important;
        font-size: 14px !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th { font-size: 0 !important; }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th::before { font-size: 14px !important; }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.leo-m8-summary-shipping {
        order: 3 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.order-total {
        order: 5 !important;
    }
}

/* Tablet: frete/retirada vem antes do desconto; sem mover nós nem depender do AJAX. */
@media (min-width: 768px) and (max-width: 1024px) {
    body.woocommerce-cart .cart_totals table.shop_table tbody {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.woocommerce-shipping-totals.shipping {
        order: 1 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-subtotal {
        order: 2 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
        order: 4 !important;
        padding: 0 0 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th,
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
        padding: 11px 0 !important;
        border-bottom: 1px solid #ededed !important;
        font-size: 14px !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th { font-size: 0 !important; }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th::before { font-size: 14px !important; }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.leo-tablet-shipping-summary {
        order: 3 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.order-total {
        order: 5 !important;
    }
}


/* ============================================================
   v0.5.11.296 — ordem e link discreto sob a legenda Desconto.
   A regra atua somente na apresentação: não modifica o <tr>, o valor,
   o <a> de remoção, o AJAX ou o cálculo de entrega/cupom.
   ============================================================ */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
    position: relative !important;
    padding-bottom: 27px !important;
}

/* O link nativo continua no DOM/célula original, com a mesma ação. */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon {
    position: absolute !important;
    left: 16px !important;
    right: auto !important;
    bottom: 12px !important;
    margin: 0 !important;
    text-align: left !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
}

/* Separação visual abaixo do link, na mesma linha financeira. */
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > th,
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td {
    padding-bottom: 0 !important;
    border-bottom: 0 !important;
}
body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
    box-shadow: inset 0 -1px 0 #ededed !important;
}

@media (min-width: 768px) and (max-width: 1024px) {
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon {
        left: 0 !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
        padding-bottom: 30px !important;
    }
}
@media (max-width: 767px) {
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount > td a.woocommerce-remove-coupon {
        left: 15px !important;
    }
    body.woocommerce-cart .cart_totals table.shop_table tbody > tr.cart-discount {
        padding-bottom: 29px !important;
    }
}
