/**
 * FD Add to Cart — Checkout / Cart Page Fixes
 *
 * Fixes:
 *  1. Order total "includes tax" text wrapping at ₹ symbol
 *  2. Tax label alignment in order review table
 *  3. Shipping method row layout
 *
 * @version 1.0.0
 */

/* =======================================================================
   ORDER TOTAL ROW — fix tax sub-text alignment
   The <small class="includes_tax"> inside tr.order-total td breaks
   at the ₹ / currency symbol causing ugly multi-line splits.
   ======================================================================= */

/* Make the total cell a flex column so price + tax text stack cleanly */
.woocommerce-checkout-review-order-table tfoot tr.order-total td,
.woocommerce table.shop_table tfoot tr.order-total td,
.cart_totals table.shop_table tfoot tr.order-total td {
    display: table-cell; /* keep table layout */
    vertical-align: top;
}

/* The actual total amount — keep on its own line */
.woocommerce-checkout-review-order-table tfoot tr.order-total td .woocommerce-Price-amount,
.woocommerce table.shop_table tfoot tr.order-total td .woocommerce-Price-amount,
.cart_totals table.shop_table tfoot tr.order-total td .woocommerce-Price-amount {
    display: block;
    font-size: 1.1em;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap !important;
}

/* ── includes_tax small text ─────────────────────────────────────────── */

.woocommerce-checkout-review-order-table tfoot tr.order-total td small.includes_tax,
.woocommerce table.shop_table tfoot tr.order-total td small.includes_tax,
.cart_totals table.shop_table tfoot tr.order-total td small.includes_tax,
tfoot tr.order-total td small.includes_tax {
    display: block !important;
    font-size: 11px !important;
    font-weight: 400 !important;
    color: #666 !important;
    line-height: 1.5 !important;
    margin-top: 4px !important;

    /* Prevent breaking between ₹ symbol and the number */
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    hyphens: none !important;
}

/* Each tax amount span — keep ₹ and digits together on same line */
.woocommerce-checkout-review-order-table tfoot tr.order-total td small.includes_tax .woocommerce-Price-amount,
.woocommerce table.shop_table tfoot tr.order-total td small.includes_tax .woocommerce-Price-amount,
tfoot tr.order-total td small.includes_tax .woocommerce-Price-amount {
    display: inline !important;
    font-size: inherit !important;
    font-weight: inherit !important;

    /* Critical: keep currency symbol + number together, never break them */
    white-space: nowrap !important;
}

/* Keep the bdi (currency wrapper) unbroken */
.woocommerce-checkout-review-order-table tfoot tr.order-total td small.includes_tax bdi,
.woocommerce table.shop_table tfoot tr.order-total td small.includes_tax bdi,
tfoot tr.order-total td small.includes_tax bdi {
    white-space: nowrap !important;
    unicode-bidi: embed !important;
}

/* =======================================================================
   ORDER TOTAL LABEL — align to top (not middle) when tax text wraps
   ======================================================================= */

.woocommerce-checkout-review-order-table tfoot tr.order-total th,
.woocommerce table.shop_table tfoot tr.order-total th,
.cart_totals table.shop_table tfoot tr.order-total th {
    vertical-align: top !important;
    padding-top: 14px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
}

/* =======================================================================
   SHIPPING METHOD TABLE — row alignment
   ======================================================================= */

.woocommerce-checkout-review-order-table tfoot tr.shipping td,
.woocommerce table.shop_table tfoot tr.shipping td {
    vertical-align: middle !important;
}

/* =======================================================================
   MOBILE — tighten up checkout total section
   ======================================================================= */

@media (max-width: 767px) {

    /* Prevent mobile order total cell squashing by using flexbox instead of table layout */
    .woocommerce-checkout-review-order-table tfoot tr.order-total,
    .woocommerce table.shop_table tfoot tr.order-total,
    .cart_totals table.shop_table tfoot tr.order-total,
    tr.order-total {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 12px 10px !important;
        border-top: 1px solid #eeeeee !important;
        border-bottom: 1px solid #eeeeee !important;
    }

    .woocommerce-checkout-review-order-table tfoot tr.order-total th,
    .woocommerce table.shop_table tfoot tr.order-total th,
    .cart_totals table.shop_table tfoot tr.order-total th,
    tr.order-total th {
        display: block !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        text-align: left !important;
    }

    .woocommerce-checkout-review-order-table tfoot tr.order-total td,
    .woocommerce table.shop_table tfoot tr.order-total td,
    .cart_totals table.shop_table tfoot tr.order-total td,
    tr.order-total td {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        width: auto !important;
        text-align: right !important;
        padding: 0 !important;
        margin: 0 0 0 auto !important; /* Pushes the td cell to the absolute right side */
        border: none !important;
    }

    .woocommerce-checkout-review-order-table tfoot tr.order-total td small.includes_tax,
    .woocommerce table.shop_table tfoot tr.order-total td small.includes_tax,
    tfoot tr.order-total td small.includes_tax {
        font-size: 10px !important;
        line-height: 1.6 !important;
        word-break: break-word !important;
    }

    /* Prevent the tax label lines from being too cramped on small screens */
    tfoot tr.order-total td small.includes_tax .woocommerce-Price-amount,
    tfoot tr.order-total td small.includes_tax bdi {
        white-space: nowrap !important;
    }

    /* Make order totals table full width on mobile */
    .woocommerce table.shop_table.woocommerce-checkout-review-order-table,
    .woocommerce-checkout .woocommerce-checkout-review-order-table {
        font-size: 13px !important;
    }
}

/* =======================================================================
   VIVID ALIGNED TAX GRID
   Formats stacked taxes into a clean 2-column layout (label left, amount right)
   ======================================================================= */

.vivid-tax-grid {
    display: inline-flex !important;
    flex-direction: column !important;
    width: auto !important;
    min-width: 150px !important;
    margin-top: 6px !important;
    text-align: left !important;
    float: right !important;
}

.vivid-tax-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 16px !important;
    width: 100% !important;
    line-height: 1.6 !important;
}

.vivid-tax-label {
    text-align: left !important;
    white-space: nowrap !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
}

.vivid-tax-amount {
    text-align: right !important;
    white-space: nowrap !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
}
