/* ==========================================================================
   Sagmart Cart Page Styles
   ========================================================================== */

/* Accessible hidden text */
.screen-reader-text {
    border: 0 !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    -webkit-clip-path: inset(50%) !important;
    clip-path: inset(50%) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    white-space: nowrap !important;
}

/* Main Cart Container */
.woocommerce-cart .sagmart-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 30px 16px 60px 16px;
    box-sizing: border-box;
}

/* Two-Column Responsive Layout: cart table + widened totals */
.woocommerce-cart .woocommerce {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 32px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* Responsive breakpoint for laptops/tablets */
@media (max-width: 1024px) {
    .woocommerce-cart .woocommerce {
        grid-template-columns: 100%;
        gap: 30px;
    }
}

/* WooCommerce Notices wrapper spans full width */
.woocommerce-cart .woocommerce .woocommerce-notices-wrapper {
    grid-column: 1 / -1;
    width: 100%;
    margin-bottom: 10px;
}

/* Left Column: Cart Form & Items Table */
.woocommerce-cart .woocommerce .woocommerce-cart-form {
    width: 100%;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--color-border);
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
    overflow-x: auto;
}

/* Right Column: Cart Totals */
.woocommerce-cart .woocommerce .cart-collaterals {
    width: 100% !important;
    float: none !important;
    box-sizing: border-box;
}

/* ==========================================================================
   PRODUCT TABLE & COLUMN ALIGNMENT
   ========================================================================== */
table.shop_table.cart {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto !important;
    box-sizing: border-box !important;
    border: none !important;
    margin: 0 !important;
}

/* Header Row */
table.shop_table.cart thead th {
    padding: 14px 8px !important;
    border-bottom: 2px solid var(--color-border) !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    color: var(--color-secondary) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

/* Table Body Cells */
table.shop_table.cart tbody td {
    padding: 16px 8px !important;
    border-bottom: 1px solid var(--color-border) !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}

/* Column 1: Remove Item Icon (36px) */
table.shop_table.cart th.product-remove,
table.shop_table.cart td.product-remove {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 40px !important;
    padding: 14px 4px !important;
    text-align: center !important;
}
table.shop_table.cart .product-remove a.remove {
    color: #94a3b8;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #f8fafc;
    transition: all 0.2s ease;
    line-height: 1;
}
table.shop_table.cart .product-remove a.remove:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: scale(1.1);
}

/* Column 2: Product Thumbnail (80px) */
table.shop_table.cart th.product-thumbnail,
table.shop_table.cart td.product-thumbnail {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    padding: 14px 6px !important;
    text-align: center !important;
}
table.shop_table.cart .product-thumbnail a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 70px !important;
    height: 70px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 4px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin: 0 auto !important;
    transition: border-color 0.2s ease;
}
table.shop_table.cart .product-thumbnail a:hover {
    border-color: var(--color-primary) !important;
}
table.shop_table.cart .product-thumbnail img {
    width: 100% !important;
    height: 100% !important;
    max-width: 62px !important;
    max-height: 62px !important;
    object-fit: contain !important;
    border: none !important;
    background: transparent !important;
    border-radius: 6px !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Column 3: Product Name (Flexible) */
table.shop_table.cart th.product-name,
table.shop_table.cart td.product-name {
    text-align: left !important;
    padding: 14px 12px !important;
}
table.shop_table.cart .product-name a {
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 15px;
    line-height: 1.4;
    word-break: normal !important;        /* NEVER BREAK PER CHARACTER */
    overflow-wrap: break-word !important; /* ONLY WRAP AT WORDS */
    white-space: normal !important;
    display: inline-block !important;
    transition: color 0.2s ease;
}
table.shop_table.cart .product-name a:hover {
    color: var(--color-accent);
}

/* Column 4: Unit Price (Right aligned) */
table.shop_table.cart th.product-price,
table.shop_table.cart td.product-price {
    text-align: right !important;
    padding: 14px 8px !important;
    width: 90px !important;
    min-width: 80px !important;
    font-weight: 600;
    font-size: 14.5px;
    color: var(--color-primary);
    white-space: nowrap !important;
}

/* Column 5: Quantity Controls (Centered) */
table.shop_table.cart th.product-quantity,
table.shop_table.cart td.product-quantity {
    text-align: center !important;
    padding: 14px 8px !important;
    width: 125px !important;
    min-width: 120px !important;
    white-space: nowrap !important;
}

/* Plus/Minus Quantity Buttons Styling on Cart Page */
.woocommerce-cart .quantity {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1.5px solid var(--color-border) !important;
    border-radius: var(--radius-full) !important;
    overflow: hidden !important;
    height: 38px !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease;
}
.woocommerce-cart .quantity:focus-within {
    border-color: var(--color-primary) !important;
}

/* Plus/Minus Buttons */
.woocommerce-cart .quantity .qty-btn {
    width: 32px !important;
    height: 100% !important;
    border: none !important;
    background: #f8fafc !important;
    color: var(--color-primary) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s, color 0.2s !important;
    user-select: none !important;
    line-height: 1 !important;
    padding: 0 !important;
    pointer-events: auto !important;
}
.woocommerce-cart .quantity .qty-btn:hover {
    background: var(--color-primary) !important;
    color: #ffffff !important;
}

/* Quantity Input: READONLY / NON-EDITABLE BY KEYBOARD / NO BROWSER SPINNERS */
.woocommerce-cart .quantity input.qty {
    width: 38px !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    color: var(--color-primary) !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield !important;
    appearance: none !important;
    cursor: default !important;
    pointer-events: none !important;
    user-select: none !important;
}
.woocommerce-cart .quantity input.qty::-webkit-outer-spin-button,
.woocommerce-cart .quantity input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
    display: none !important;
}

/* Column 6: Subtotal (Right aligned) */
table.shop_table.cart th.product-subtotal,
table.shop_table.cart td.product-subtotal {
    text-align: right !important;
    padding: 14px 10px 14px 6px !important;
    width: 95px !important;
    min-width: 85px !important;
    font-weight: 700;
    font-size: 15px;
    color: var(--color-primary);
    white-space: nowrap !important;
}

/* ==========================================================================
   CART ACTIONS (Coupon & Update Cart Alignment - SINGLE ROW)
   ========================================================================== */
table.shop_table.cart td.actions {
    display: table-cell !important;
    padding: 24px 0 0 0 !important;
    border-bottom: none !important;
    width: 100% !important;
}

table.shop_table.cart td.actions .actions-wrapper {
    display: flex !important;
    flex-wrap: nowrap !important; /* All in ONE row */
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.actions .coupon {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 0 1 auto !important;
    margin: 0 !important;
}

.actions .coupon input#coupon_code {
    width: 160px !important;
    max-width: 180px !important;
    height: 42px !important;
    padding: 0 16px !important;
    border: 1.5px solid var(--color-border) !important;
    border-radius: var(--radius-full) !important;
    outline: none !important;
    font-size: 13.5px !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    transition: border-color 0.2s;
}
.actions .coupon input#coupon_code:focus {
    border-color: var(--color-primary) !important;
}

.actions .coupon button[name="apply_coupon"] {
    height: 42px !important;
    padding: 0 20px !important;
    background: var(--color-secondary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--radius-full) !important;
    cursor: pointer !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    transition: all 0.25s ease !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}
.actions .coupon button[name="apply_coupon"]:hover {
    background: var(--color-primary) !important;
}

.actions button[name="update_cart"] {
    height: 42px !important;
    padding: 0 22px !important;
    background: transparent !important;
    border: 2px solid var(--color-primary) !important;
    color: var(--color-primary) !important;
    border-radius: var(--radius-full) !important;
    cursor: pointer !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    transition: all 0.25s ease !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}
.actions button[name="update_cart"]:hover:not(:disabled) {
    background: var(--color-primary) !important;
    color: #ffffff !important;
}
.actions button[name="update_cart"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--color-border);
    color: var(--color-secondary);
}

/* ==========================================================================
   CART TOTALS BOX
   ========================================================================== */
.cart-collaterals .cart_totals {
    width: 100% !important;
    background: #fbfbfc;
    padding: 24px 24px 28px 24px !important;
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
}

.cart_totals h2 {
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 12px 0 !important;
    padding-bottom: 10px !important;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-border);
    letter-spacing: -0.2px;
}

.cart_totals table {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    box-sizing: border-box !important;
}

.cart_totals th,
.cart_totals td {
    padding: 14px 14px !important;
    border-bottom: 1px solid var(--color-border) !important;
    box-sizing: border-box !important;
    vertical-align: middle !important;
}

.cart_totals th {
    width: 40% !important;
    text-align: left !important;
    color: var(--color-secondary) !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    padding-left: 14px !important;
    padding-right: 10px !important;
}

.cart_totals td {
    width: 60% !important;
    text-align: right !important;
    font-weight: 600 !important;
    font-size: 14.5px !important;
    color: var(--color-primary) !important;
    word-break: normal !important;
    padding-right: 14px !important;
    padding-left: 10px !important;
}

/* Shipping Methods Row - Full-Width Native Table Cell (Spans 100% of Box) */
.cart_totals tr.shipping,
.cart_totals tr.sagmart-shipping-totals-row {
    display: table-row !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.cart_totals tr.shipping td.sagmart-shipping-full-cell,
.cart_totals tr.sagmart-shipping-totals-row td.sagmart-shipping-full-cell {
    display: table-cell !important;
    width: 100% !important;
    padding: 14px 14px !important;
    border-bottom: 1px solid var(--color-border) !important;
    text-align: left !important;
    box-sizing: border-box !important;
}

.sagmart-shipping-header-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}

.sagmart-shipping-header-row .shipping-header-label {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--color-secondary) !important;
}

.sagmart-cart-shipping-box {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    box-sizing: border-box !important;
}

/* Shipping Status Badges */
.sagmart-shipping-status-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 5px 12px !important;
    border-radius: 9999px !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
}

.sagmart-shipping-status-badge.badge-free-delivery,
.sagmart-shipping-status-badge {
    background: #f0fdf4 !important;
    color: #16a34a !important;
    border: 1px solid #bbf7d0 !important;
}

.sagmart-shipping-status-badge.badge-standard-delivery {
    background: #eff6ff !important;
    color: #0047ff !important;
    border: 1px solid #bfdbfe !important;
}

.sagmart-free-shipping-upsell-bar {
    width: 100% !important;
    background: #fffbeb !important;
    color: #b45309 !important;
    border: 1px dashed #fde68a !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/* Full-Width Delivery Address Card */
.sagmart-delivery-address-card {
    width: 100% !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    box-sizing: border-box !important;
}

.sagmart-delivery-address-card .address-card-header {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    color: #475569 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 6px !important;
}

.sagmart-delivery-address-card .address-destination-text {
    margin: 0 0 10px 0 !important;
    font-size: 13.5px !important;
    line-height: 1.5 !important;
    color: #1e293b !important;
    font-weight: 500 !important;
    text-align: left !important;
}

.sagmart-delivery-address-card .address-change-action {
    display: flex !important;
    justify-content: flex-start !important;
}

.sagmart-change-addr-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    color: #0047ff !important;
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
    padding: 5px 12px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
}

.sagmart-change-addr-link:hover {
    background: #dbeafe !important;
    color: #0036cc !important;
}

/* Shipping Calculator Full-Width Form */
form.woocommerce-shipping-calculator {
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    margin-top: 8px !important;
    box-sizing: border-box !important;
    text-align: left !important;
}

form.woocommerce-shipping-calculator .form-row {
    width: 100% !important;
    margin-bottom: 10px !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

form.woocommerce-shipping-calculator select,
form.woocommerce-shipping-calculator input.input-text {
    width: 100% !important;
    padding: 10px 12px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 13.5px !important;
    color: #0f172a !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
}

form.woocommerce-shipping-calculator button.button {
    width: 100% !important;
    padding: 11px !important;
    border-radius: 8px !important;
    background: #0f172a !important;
    color: #ffffff !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    border: none !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
    box-sizing: border-box !important;
}

form.woocommerce-shipping-calculator button.button:hover {
    background: #1e293b !important;
}

/* Order Total Row */
.cart_totals .order-total th,
.cart_totals .order-total td {
    border-bottom: none !important;
    border-top: 2px solid var(--color-border) !important;
    padding-top: 18px !important;
    padding-bottom: 14px !important;
}
.cart_totals .order-total th {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--color-primary) !important;
    padding-left: 14px !important;
    padding-right: 10px !important;
}
.cart_totals .order-total td {
    font-size: 20px !important;
    font-weight: 800 !important;
    color: var(--color-primary) !important;
    padding-right: 14px !important;
    padding-left: 10px !important;
}

/* Proceed to Checkout Button */
.wc-proceed-to-checkout {
    margin-top: 20px;
    width: 100%;
}
.wc-proceed-to-checkout .checkout-button {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    text-align: center;
    background: var(--color-primary);
    color: #ffffff !important;
    padding: 16px 20px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.wc-proceed-to-checkout .checkout-button:hover {
    background: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

/* ==========================================================================
   MOBILE RESPONSIVE (Cards stack under 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .woocommerce-cart .sagmart-container {
        padding: 20px 12px 40px 12px;
    }
    .woocommerce-cart .woocommerce .woocommerce-cart-form {
        padding: 18px 14px;
    }
    .cart-collaterals .cart_totals {
        padding: 20px 16px;
    }

    /* Convert Shop Table to Responsive Card Stack */
    table.shop_table.cart {
        min-width: 0 !important;
    }
    table.shop_table.cart thead {
        display: none !important;
    }
    table.shop_table.cart tbody tr {
        display: grid !important;
        grid-template-columns: 26px 68px 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 6px 10px !important;
        align-items: center !important;
        padding: 14px 0 !important;
        border-bottom: 1px solid var(--color-border) !important;
        position: relative !important;
    }
    table.shop_table.cart tbody td {
        padding: 0 !important;
        border-bottom: none !important;
        width: auto !important;
        min-width: 0 !important;
    }
    table.shop_table.cart .product-remove {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }
    table.shop_table.cart .product-thumbnail {
        grid-column: 2 !important;
        grid-row: 1 / 4 !important;
        width: 68px !important;
    }
    table.shop_table.cart .product-thumbnail a,
    table.shop_table.cart .product-thumbnail img {
        width: 60px !important;
        min-width: 60px !important;
        max-width: 60px !important;
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
    }
    table.shop_table.cart .product-name {
        grid-column: 3 !important;
        grid-row: 1 !important;
    }
    table.shop_table.cart .product-price {
        grid-column: 3 !important;
        grid-row: 2 !important;
        text-align: left !important;
    }
    table.shop_table.cart .product-quantity {
        grid-column: 3 !important;
        grid-row: 3 !important;
        text-align: left !important;
        margin-top: 4px !important;
    }
    table.shop_table.cart .product-subtotal {
        grid-column: 3 !important;
        grid-row: 4 !important;
        text-align: left !important;
        margin-top: 4px !important;
        font-size: 16px !important;
    }
    table.shop_table.cart .product-subtotal::before {
        content: "Subtotal: ";
        font-size: 12.5px;
        font-weight: 500;
        color: var(--color-secondary);
    }

    /* Actions row on mobile */
    table.shop_table.cart tbody tr:last-child {
        display: block !important;
        padding-top: 14px !important;
    }
    table.shop_table.cart td.actions {
        display: block !important;
        width: 100% !important;
        padding: 16px 0 0 0 !important;
    }
    table.shop_table.cart td.actions .actions-wrapper {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }
    .actions .coupon {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    .actions .coupon input#coupon_code {
        width: 100% !important;
        max-width: none !important;
        height: 42px !important;
        box-sizing: border-box !important;
    }
    .actions .coupon button[name="apply_coupon"] {
        width: 100% !important;
        height: 42px !important;
        box-sizing: border-box !important;
        padding: 0 16px !important;
    }
    .actions button[name="update_cart"] {
        width: 100% !important;
        height: 42px !important;
        box-sizing: border-box !important;
        margin-left: 0 !important;
    }
}
