/* ===========================
   WooCommerce Cart
=========================== */

/* ══ Cart Items Table — Mobile ════════════════════════════════════
   CSS Grid 3-column: [รูป 170px] [label:value 1fr] [× 36px]
   ทุก rule อยู่ใน @media (max-width: 768px) → ไม่กระทบ desktop/tablet
═══════════════════════════════════════════════════════════════════ */
@media only screen and (max-width: 768px) {

    /* ── tr: grid container ── */
    .woocommerce .woocommerce-cart-form table.cart tr.cart_item,
    .woocommerce-page .woocommerce-cart-form table.cart tr.cart_item {
        display: grid !important;
        grid-template-columns: 170px 1fr 36px !important;
        grid-template-rows: auto auto auto auto !important;
        column-gap: 12px !important;
        row-gap: 0 !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 16px 0 !important;
        border-top: none !important;
        border-bottom: 1px solid #e0e0e0 !important;
        border-radius: 0 !important;
        position: static !important;
    }

    /* ── col 1 · row 1-4: thumbnail ── */
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail {
        grid-column: 1 !important;
        grid-row: 1 / span 4 !important;
        display: block !important;
        padding: 0 !important;
        width: auto !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail::before {
        display: none !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail a,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail a {
        display: block !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail img,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-thumbnail img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
        border-radius: 4px !important;
    }

    /* ── col 2 · rows 1-4: label:value rows ── */
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-name,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-name {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-price,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-price {
        grid-column: 2 !important;
        grid-row: 2 !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity {
        grid-column: 2 !important;
        grid-row: 3 !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal {
        grid-column: 2 !important;
        grid-row: 4 !important;
    }

    /* label:value — flex, label fixed width */
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-name,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-price,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-name,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-price,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal {
        display: flex !important;
        align-items: center !important;
        min-width: 0 !important;
        padding: 5px 0 !important;
        text-align: left !important;
        /*border-bottom: 0.5px solid #e0e0e0 !important;*/
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal {
        border-bottom: none !important;
    }

    /* ::before = label column */
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-name::before,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-price::before,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity::before,
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-name::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-price::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-quantity::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-subtotal::before {
        min-width: 72px !important;
        flex-shrink: 0 !important;
        float: none !important;
        font-weight: 600 !important;
        text-align: left !important;
    }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-name a,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-name a {
        font-weight: 600;
    }

    /* ── col 3 · row 1: × button ── */
    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-remove,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-remove {
        grid-column: 3 !important;
        grid-row: 1 !important;
        display: flex !important;
        align-items: start !important;
        justify-content: center !important;
        padding: 0px 0 0 !important;
        width: auto !important;
        position: static !important;
        margin-top: -60px !important;
    }

    .woocommerce-cart a.remove {
        font-size: 26px
     }

    .woocommerce .woocommerce-cart-form table.shop_table_responsive tr td.product-remove::before,
    .woocommerce-page .woocommerce-cart-form table.shop_table_responsive tr td.product-remove::before {
        display: none !important;
    }

    /* ── Update Cart button — full width ── */
    .woocommerce-cart-form .actions button[name="update_cart"] {
        width: 100% !important;
        display: block !important;
        box-sizing: border-box !important;
    }
   .elementor-widget-woocommerce-cart .woocommerce table.shop_table.cart tbody tr:last-child {
        width: 100% !important;
        display: block !important;
        padding: 0;
    }

}


/* ══ Cart Empty — ข้อความ "Your cart is currently empty." ════════
   ป้องกัน toast JS/CSS ทำให้ข้อความหายไป
═══════════════════════════════════════════════════════════════════ */
.woocommerce-cart p.cart-empty.woocommerce-info {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    position: relative !important;
    margin-bottom: 20px !important;
}

/* ══ Cart Totals — ทุก device ════════════════════════════════════
   ใช้ .elementor-widget-woocommerce-cart เป็น anchor สำหรับ specificity สูง
═══════════════════════════════════════════════════════════════════ */

/* 5. หัวข้อ Cart Totals — center */
.cart_totals > h2 {
    text-align: center;
}

/* 6. td ชิดซ้าย — selector เดียวกับ Elementor Pro แต่โหลดทีหลัง → ชนะ source order */
.elementor-widget-woocommerce-cart .woocommerce .cart_totals table.shop_table_responsive tr td,
.elementor-widget-woocommerce-cart .woocommerce-page .cart_totals table.shop_table_responsive tr td {
    text-align: start !important;
}

/* price amount อยู่ขวา — ไม่พึ่ง text-align ของ parent td */
.elementor-widget-woocommerce-cart .woocommerce .cart_totals table.shop_table_responsive tr td span.woocommerce-Price-amount,
.elementor-widget-woocommerce-cart .woocommerce-page .cart_totals table.shop_table_responsive tr td span.woocommerce-Price-amount {
    display: flex;
    justify-content: flex-end;
}


/* ══ Change Address → Pencil Icon — ทุก device ═══════════════════ */

.cart_totals .woocommerce-shipping-totals {
    position: relative;
}

.cart_totals .woocommerce-shipping-totals td {
    padding-right: 36px !important;
}

.shipping-calculator-button {
    font-size: 0 !important;
    width: 28px !important;
    height: 28px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    opacity: 0.5;
    transition: opacity .2s;
}

.shipping-calculator-button:hover {
    opacity: 1 !important;
}

/* Heroicons pencil-square outline */
.shipping-calculator-button::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%23000'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}
