/* ==========================================================================
   Modern Cart & Checkout Styling for Sparko Theme
   ========================================================================== */

/* -------------------------------------
   1. Premium Minimal Cart Page Styles
   ------------------------------------- */

.bg-primary-custom {
    background-color: var(--primary-color) !important;
    color: #fff !important;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.text-secondary-custom {
    color: var(--secondary-color) !important;
}

.hover-primary {
    transition: color 0.3s ease;
}

.hover-primary:hover {
    color: var(--primary-color) !important;
}

/* Enforce Vazirmatn in Cart & Checkout Components */
.nim-cart-item *, .cart_totals *, .woocommerce-cart-form * {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}
.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands, [class*=" fa-"], [class^="fa-"], i[class*="fa"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome" !important;
}

/* Prevent Chrome flexbox character breaking bug on product titles */
.nim-cart-item .fs-6,
.nim-cart-item .fs-6 a,
.woocommerce-cart-form__cart-item .fs-6,
.woocommerce-cart-form__cart-item .fs-6 a,
.product-info .fs-6,
.product-info .fs-6 a {
    word-break: keep-all !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    display: inline-block !important;
}

/* Cart Item Overrides */
.nim-cart-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-top: 1px solid #dee2e6 !important; /* Outer card top border */
}

.nim-cart-item > div > div {
    border-top: none !important;
}

.woocommerce table.shop_table tr.woocommerce-cart-form__cart-item td,
.woocommerce table.shop_table tr.woocommerce-cart-form__cart-item {
    border-top: none !important;
}

.nim-cart-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05) !important;
}

/* Quantity Input */
.nim-qty-input {
    width: 100% !important;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    box-shadow: none !important;
    transition: all 0.3s ease;
}
.nim-qty-input:focus {
    background-color: #fff !important;
    border: 1px solid var(--primary-color) !important;
}

/* Remove Button */
.nim-remove-btn {
    transition: all 0.3s ease;
}
.nim-remove-btn:hover {
    background-color: #dc3545 !important;
    color: #fff !important;
    transform: scale(1.1) rotate(90deg);
}

/* Button Custom Primary */
.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transition: all 0.3s ease;
}
.btn-primary-custom:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(90, 111, 220, 0.3);
}

/* Checkout Button Animation */
.nim-checkout-btn i {
    transition: transform 0.3s ease;
}
.nim-checkout-btn:hover i {
    transform: translateX(-5px); /* Move left because of RTL */
}

/* Cart Totals Table */
.nim-totals-table th {
    font-weight: normal;
    text-align: right;
}
.nim-totals-table td {
    text-align: left;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .nim-cart-item {
        padding: 1.25rem !important;
    }
}


/* WooCommerce Notices (e.g. "Item removed. Undo?") */
.woocommerce-message,
.woocommerce-error,
.woocommerce-info {
    background: #ffffff;
    border: 1px solid #eef0fb;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    color: var(--secondary-color);
    font-size: 0.95rem;
    font-weight: 500;
    list-style: none; /* For error lists */
}

.woocommerce-error li {
    margin: 0;
}

.woocommerce-message::before,
.woocommerce-error::before,
.woocommerce-info::before {
    display: none !important; /* Hide default WC icons */
}

.woocommerce-message {
    border-right: 4px solid #10b981; /* Green */
}

.woocommerce-error {
    border-right: 4px solid #ef4444; /* Red */
}

.woocommerce-info {
    border-right: 4px solid var(--primary-color);
}

.woocommerce-message .button,
.woocommerce-error .button,
.woocommerce-info .button {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    font-size: 0.85rem !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    float: left !important; /* Move button to left in RTL */
    border: none !important;
}

.woocommerce-message .button:hover,
.woocommerce-error .button:hover,
.woocommerce-info .button:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(90, 111, 220, 0.2) !important;
}

/* Loading Dots Animation */
.nim-dots-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    width: 100%;
}
.nim-dots-loader span {
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: nim-dots 1s infinite alternate;
}
.nim-dots-loader span:nth-child(2) {
    animation-delay: 0.2s;
}
.nim-dots-loader span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes nim-dots {
    to {
        opacity: 0.3;
        transform: translateY(-3px);
    }
}

/* -------------------------------------
   2. Checkout Page Styles
   ------------------------------------- */

/* Checkout Coupon Custom Styles */
.woocommerce-form-coupon-toggle .woocommerce-info {
    background: #fdfdfd;
    border: 1px dashed #eef0fb;
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 25px;
    color: var(--secondary-color);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.woocommerce-form-coupon-toggle .woocommerce-info::before {
    display: none;
}

.woocommerce-form-coupon-toggle .woocommerce-info a {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.3s ease;
}

.woocommerce-form-coupon-toggle .woocommerce-info a:hover {
    text-decoration: underline;
}

form.checkout_coupon {
    background: #ffffff;
    border: 1px solid #eef0fb;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

form.checkout_coupon p {
    margin-bottom: 0;
}

form.checkout_coupon p:first-child {
    width: 100%;
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

form.checkout_coupon p.form-row-first {
    flex: 1;
    min-width: 250px;
}

form.checkout_coupon p.form-row-last {
    flex-shrink: 0;
}

form.checkout_coupon input.input-text {
    width: 100%;
    border: 2px solid #eef0fb;
    border-radius: 12px;
    padding: 12px 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
    background: #fcfcfc;
}

form.checkout_coupon input.input-text:focus {
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(90, 111, 220, 0.1);
}

form.checkout_coupon button.button {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #7c3aed 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 12px 25px;
    font-weight: 700;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2);
}

form.checkout_coupon button.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3);
}

/* -------------------------------------

/* Form Input Layout */
.woocommerce-checkout .form-row {
    margin-bottom: 20px;
    width: 100%;
}

.woocommerce-checkout .form-row label {
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 8px;
    display: block;
}

.woocommerce-checkout .form-row input.input-text,
.woocommerce-checkout .form-row select,
.woocommerce-checkout .form-row textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #eef0fb;
    border-radius: 12px;
    background-color: #fcfcfc;
    transition: all 0.3s ease;
    font-family: inherit;
    outline: none;
}

.woocommerce-checkout .form-row input.input-text:focus,
.woocommerce-checkout .form-row select:focus,
.woocommerce-checkout .form-row textarea:focus {
    border-color: var(--primary-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(90, 111, 220, 0.1);
}

/* Select2 overrides for WC Country/State fields */
.select2-container--default .select2-selection--single {
    border: 2px solid #eef0fb !important;
    border-radius: 12px !important;
    height: 50px !important;
    background-color: #fcfcfc !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 46px !important;
    padding-right: 15px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px !important;
}

/* Checkout Review Table */
.woocommerce-checkout-review-order-table {
    width: 100%;
    margin-bottom: 2rem;
}

.woocommerce-checkout-review-order-table th,
.woocommerce-checkout-review-order-table td {
    padding: 15px 0;
    border-bottom: 1px dashed #eef0fb;
}

.woocommerce-checkout-review-order-table thead th {
    border-bottom: 2px solid #eef0fb;
    font-weight: 700;
}

.woocommerce-checkout-review-order-table .product-name {
    text-align: right;
}

.woocommerce-checkout-review-order-table .product-total {
    text-align: left;
    font-weight: 700;
}

.woocommerce-checkout-review-order-table tfoot th {
    text-align: right;
    font-weight: 600;
}

.woocommerce-checkout-review-order-table tfoot td {
    text-align: left;
    font-weight: 700;
    color: var(--primary-color);
}

/* Payment Gateway Box */
#payment {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
}

#payment ul.payment_methods {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    border-bottom: 1px solid #eef0fb;
}

#payment ul.payment_methods li {
    margin-bottom: 15px;
}

#payment ul.payment_methods li input[type="radio"] {
    margin-left: 10px;
}

#payment ul.payment_methods li label {
    font-weight: 700;
    cursor: pointer;
}

#payment div.payment_box {
    background: #ffffff;
    padding: 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 10px;
    position: relative;
    border: 1px solid #eef0fb;
}

#payment div.payment_box::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 30px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ffffff;
}

/* Place Order Area */

#payment button#place_order {
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #9333ea 100%) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(90, 111, 220, 0.3) !important;
    transition: all 0.3s ease;
}

#payment button#place_order:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(90, 111, 220, 0.4) !important;
}

/* Style the Return to Cart link */
#payment .return-to-cart-btn {
    color: var(--secondary-color);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#payment .return-to-cart-btn:hover {
    color: var(--primary-color);
    background: #f8f9fa;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .woocommerce-cart-form__cart-item {
        display: block !important;
        text-align: center;
        background: #fdfdfd;
        border-radius: 15px;
        margin-bottom: 20px;
        padding: 15px;
    }

    .woocommerce-cart-form__cart-item td {
        display: block;
        text-align: center !important;
        padding: 10px;
    }

    .product-remove a.remove {
        margin: 0 auto;
    }

    .woocommerce-cart-form__contents thead {
        display: none;
        /* Hide table headers on mobile */
    }

    .woocommerce-cart-form .coupon {
        float: none;
        flex-direction: column;
        width: 100%;
        margin-bottom: 15px;
    }

    .woocommerce-cart-form .coupon input.input-text {
        width: 100%;
    }

    .woocommerce-cart-form button[name="update_cart"] {
        float: none;
        width: 100%;
    }
}

/* -------------------------------------
   3. WooCommerce Blocks Compatibility
   ------------------------------------- */

/* Proceed to Checkout / Place Order Blocks */
.wc-block-components-button:not(.is-link),
.wc-block-cart__submit-button,
.wc-block-components-checkout-place-order-button,
.wp-block-woocommerce-proceed-to-checkout-block .wc-block-components-button {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #a251ea 100%) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 12px 24px !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
    font-family: inherit !important;
    letter-spacing: 0.5px !important;
    box-shadow: 0 4px 15px rgba(90, 111, 220, 0.2) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    text-decoration: none !important;
}

.wc-block-components-button:not(.is-link):hover,
.wc-block-cart__submit-button:hover,
.wc-block-components-checkout-place-order-button:hover,
.wp-block-woocommerce-proceed-to-checkout-block .wc-block-components-button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(90, 111, 220, 0.35) !important;
    color: #ffffff !important;
}

/* Secondary Block Buttons (e.g. Apply Coupon) */
.wc-block-components-totals-coupon__button {
    background: #f8f9fa !important;
    color: var(--secondary-color) !important;
    border: 2px solid #eef0fb !important;
    border-radius: 50px !important;
    box-shadow: none !important;
}

.wc-block-components-totals-coupon__button:hover {
    background: #eef0fb !important;
    color: var(--primary-color) !important;
}

/* Checkout Block Form Inputs & Selects */
.wc-block-components-text-input input[type="text"],
.wc-block-components-text-input input[type="email"],
.wc-block-components-text-input input[type="tel"],
.wc-block-components-textarea textarea,
.wc-blocks-components-select__select {
    width: 100% !important;
    display: block !important;
    border: 2px solid #eef0fb !important;
    border-radius: 12px !important;
    padding: 14px 20px !important;
    font-size: 0.95rem !important;
    background-color: #fcfcfc !important;
    transition: all 0.3s ease !important;
    box-shadow: none !important;
    color: var(--secondary-color) !important;
    font-family: inherit !important;
}

.wc-block-components-text-input input:focus,
.wc-block-components-textarea textarea:focus,
.wc-blocks-components-select__select:focus {
    border-color: var(--primary-color) !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(90, 111, 220, 0.1) !important;
    outline: none !important;
}

/* Floating labels in WC blocks */
.wc-block-components-text-input label,
.wc-blocks-components-select__label {
    color: #6c757d !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    padding-right: 15px !important;
    /* RTL context */
    background: transparent !important;
    z-index: 2 !important;
    transition: all 0.2s ease !important;
}

/* Fix overlapping floating labels when active */
.wc-block-components-text-input.is-active label,
.wc-block-components-text-input.has-value label {
    background: #ffffff !important;
    padding: 0 8px !important;
    z-index: 5 !important;
    transform: translateY(-80%) scale(0.9) !important;
    color: var(--primary-color) !important;
}

/* Checkout step containers (Cards) */
.wc-block-components-checkout-step {
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 30px !important;
    margin-bottom: 25px !important;
    border: 1px solid #eef0fb !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02) !important;
    transition: all 0.3s ease;
}

.wc-block-components-checkout-step:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.04) !important;
}

.wc-block-components-checkout-step__title {
    font-weight: 700 !important;
    color: var(--secondary-color) !important;
    border-bottom: 2px dashed #eef0fb !important;
    padding-bottom: 15px !important;
    margin-bottom: 25px !important;
    font-size: 1.25rem !important;
}

/* Payment Methods Radio Buttons */
.wc-block-components-radio-control {
    background: #f8f9fa !important;
    border-radius: 12px !important;
    padding: 15px !important;
    margin-bottom: 15px !important;
    border: 1px solid #eef0fb !important;
    transition: all 0.3s ease !important;
}

.wc-block-components-radio-control:hover {
    border-color: rgba(90, 111, 220, 0.3) !important;
    background: #ffffff !important;
}

/* Payment description box */
.wc-block-components-payment-method-description {
    font-size: 0.9rem !important;
    color: #6c757d !important;
    padding-top: 10px !important;
}

/* Sidebar Order Summary (Right Column) */
.wc-block-checkout__sidebar {
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 30px !important;
    border: 1px solid #eef0fb !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02) !important;
}

/* Fix RTL alignment and width of WooCommerce Checkout Block container */
.wp-block-woocommerce-checkout .wc-block-checkout {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 40px !important;
    width: 100% !important;
}

[dir="rtl"] .wp-block-woocommerce-checkout .wc-block-checkout {
    flex-direction: row !important;
    /* In RTL, row makes the first item naturally appear on the right */
    justify-content: space-between !important;
}

.wp-block-woocommerce-checkout .wc-block-checkout__main {
    flex: 1 1 60% !important;
    max-width: none !important;
}

.wp-block-woocommerce-checkout .wc-block-checkout__sidebar {
    flex: 1 1 35% !important;
    max-width: none !important;
    margin: 0 !important;
}

@media (max-width: 991px) {
    .wp-block-woocommerce-checkout .wc-block-checkout {
        flex-direction: column !important;
    }

    .wp-block-woocommerce-checkout .wc-block-checkout__main,
    .wp-block-woocommerce-checkout .wc-block-checkout__sidebar {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

.wc-block-components-totals-item__label,
.wc-block-components-totals-item__value {
    color: var(--secondary-color) !important;
    font-weight: 600 !important;
}

/* Checkout step actions (bottom buttons layout) */
.wc-block-components-checkout-step__actions,
.wc-block-checkout__actions,
.wp-block-woocommerce-checkout-order-summary-block {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    /* Put buttons on opposite ends */
    gap: 15px !important;
    flex-wrap: wrap !important;
    flex-direction: row !important;
    /* Standard row, RTL will naturally place first item on right */
    padding-top: 25px !important;
    border-top: 1px dashed #eef0fb !important;
    margin-top: 20px !important;
    width: 100% !important;
}

.wc-block-components-checkout-place-order-button {
    width: auto !important;
    min-width: 200px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 14px 30px !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    white-space: nowrap !important;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #7c3aed 100%) !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3) !important;
    border: none !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Return to Cart Button override */
.wc-block-components-checkout-return-to-cart-button {
    background: transparent !important;
    color: #6b7280 !important;
    border: 1px solid #d1d5db !important;
    box-shadow: none !important;
    padding: 10px 20px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

.wc-block-components-checkout-return-to-cart-button:hover {
    color: var(--primary-color) !important;
    background: #f8f9fa !important;
    transform: translateY(-1px) !important;
}

/* Hide WooCommerce Block Checkout Terms & Privacy Policy */
.wc-block-checkout__terms,
.wc-block-components-checkout-terms,
.wc-block-components-checkout-terms-and-conditions,
.wc-terms-and-conditions {
    display: none !important;
}

/* Mobile optimizations for bottom buttons */
@media (max-width: 768px) {

    .wc-block-components-checkout-step__actions,
    .wc-block-checkout__actions,
    .wp-block-woocommerce-checkout-order-summary-block {
        flex-direction: column !important;
        flex-wrap: wrap !important;
        background: transparent !important;
        gap: 1.5rem !important;
        /* Increased gap on mobile */
        justify-content: center !important;
        align-items: stretch !important;
    }

    .wc-block-components-checkout-place-order-button {
        width: 100% !important;
        min-width: unset !important;
        padding: 12px 15px !important;
        font-size: 1.1rem !important;
        flex: unset !important;
        white-space: normal !important;
    }

    .wc-block-components-checkout-return-to-cart-button {
        width: 100% !important;
        text-align: center !important;
        padding: 12px 10px !important;
        font-size: 0.95rem !important;
        white-space: normal !important;
        flex-shrink: 0 !important;
    }
}

/* Fix default woocommerce layouts */
.woocommerce-checkout .col2-set {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

.woocommerce-checkout .col2-set .col-1,
.woocommerce-checkout .col2-set .col-2 {
    float: none !important;
    width: 100% !important;
    flex: 1;
    min-width: 300px;
}

/* Checkout step actions (bottom buttons layout - Blocks & Normal) */
.wc-block-components-checkout-step__actions,
.wc-block-checkout__actions,
.wp-block-woocommerce-checkout-order-summary-block,
div.sparko-checkout-actions {
    display: flex !important;
    flex-direction: column !important;
    /* Stack vertically */
    align-items: center !important;
    justify-content: center !important;
    gap: 15px !important;
    padding-top: 25px !important;
    border-top: 1px dashed #eef0fb !important;
    margin-top: 20px !important;
    width: 100% !important;
}

/* Make sure place order is full width or well sized */
.wc-block-components-checkout-place-order-button,
#payment button#place_order,
#payment input#place_order {
    width: 100% !important;
    max-width: 400px !important;
    margin: 0 auto !important;
    background: linear-gradient(135deg, var(--bs-primary) 0%, #7c3aed 100%) !important;
    padding: 15px 30px !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    white-space: normal !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3) !important;
    border: none !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    order: 1 !important;
}

#payment button#place_order,
#payment input#place_order {
    display: flex !important;
}

/* Return to Cart Button override */
.wc-block-components-checkout-return-to-cart-button,
a.return-to-cart-btn {
    width: 100% !important;
    max-width: 300px !important;
    justify-content: center !important;
    margin: 0 auto !important;
    background: transparent !important;
    color: var(--secondary-color) !important;
    border: 1px solid #d1d5db !important;
    box-shadow: none !important;
    padding: 10px 20px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    gap: 5px !important;
    transition: all 0.3s ease !important;
    order: 2 !important;
}

.wc-block-components-checkout-return-to-cart-button:hover,
a.return-to-cart-btn:hover {
    color: var(--primary-color) !important;
    background: #f8f9fa !important;
    transform: translateY(-1px) !important;
}

/* -------------------------------------
   4. WooCommerce Blocks Cart Custom Styling
   ------------------------------------- */

.wp-block-woocommerce-cart {
    margin-top: 30px;
}

/* Cart Items Container */
.wc-block-cart-items {
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 30px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.03) !important;
    border: 1px solid #f8f9fa !important;
}

.wc-block-cart-items__header {
    border-bottom: 2px dashed #eef0fb !important;
    padding-bottom: 15px !important;
    margin-bottom: 20px !important;
}

.wc-block-cart-items__header span {
    font-weight: 700 !important;
    color: var(--secondary-color) !important;
    font-size: 1.1rem !important;
}

/* Modern Grid Layout for Cart Items */
.wc-block-cart-item {
    padding: 20px 0 !important;
    border-bottom: 1px dashed #eef0fb !important;
    transition: all 0.3s ease !important;
}

.wc-block-cart-item:last-child {
    border-bottom: none !important;
}

.wc-block-cart-item:hover {
    background-color: #fcfcfc !important;
    border-radius: 12px;
}

.wc-block-cart-item__wrap {
    display: grid !important;
    grid-template-columns: 80px 1fr auto !important; /* Image, Quantity, Price */
    grid-template-rows: auto auto !important;
    align-items: center !important;
    gap: 15px 20px !important;
}

/* Product Image Cell */
.wc-block-cart-item__image,
.wc-block-components-product-image {
    grid-column: 1 !important;
    grid-row: 1 !important; /* Image only in top right row */
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    border-radius: 8px !important; /* Squarish as requested in wireframe */
    overflow: hidden !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05) !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
}

.wc-block-cart-item__image img,
.wc-block-components-product-image img {
    width: 100% !important;
    height: 100% !important;
    max-width: 80px !important;
    object-fit: cover !important;
    display: block !important;
}

/* Product Info Container */
.wc-block-components-product-details {
    grid-column: 2 / span 2 !important; /* Spans under quantity and price */
    grid-row: 2 !important; /* Placed below the first row elements */
    display: block !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin-top: -5px !important;
}

.wc-block-components-product-name {
    font-weight: 800 !important;
    font-size: 1.05rem !important; 
    color: var(--secondary-color) !important;
    text-decoration: none !important;
    margin-bottom: 5px !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important; 
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.wc-block-cart-item__prices,
.wc-block-components-product-price {
    display: none !important; /* Hidden as requested */
}

/* Short Description Settings */
.wp-block-woocommerce-cart-item-description,
.wc-block-components-product-details__description,
.wc-block-components-product-description {
    display: -webkit-box !important;
    -webkit-line-clamp: 1 !important; /* 1 line limit as per wireframe */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 0.85rem !important;
    color: #666 !important;
    margin-top: 5px !important;
    line-height: 1.6 !important;
    white-space: normal !important;
    word-break: normal !important;
}

/* Ensure Variations are shown nicely */
.wc-block-components-product-details .wc-block-components-product-metadata,
.wc-block-components-product-details .wc-block-components-product-details__variation {
    display: block !important;
    font-size: 0.85rem !important;
    color: #888 !important;
    margin-top: 5px !important;
    line-height: 1.6 !important;
}

/* Quantity and Remove Wrapper */
.wc-block-cart-item__quantity {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 15px !important;
    margin: 0 !important;
    border: none !important;
    padding: 0 !important;
}

/* Quantity Control */
.wc-block-components-quantity-selector {
    background: #f8f9fa !important;
    border: 1px solid #eef0fb !important;
    border-radius: 50px !important;
    padding: 3px !important;
    display: inline-flex !important;
    align-items: center !important;
    height: 42px !important;
    box-sizing: border-box !important;
}

.wc-block-components-quantity-selector input.wc-block-components-quantity-selector__input {
    background: transparent !important;
    border: none !important;
    font-weight: 800 !important;
    font-size: 1.1rem !important;
    color: var(--secondary-color) !important;
    width: 40px !important;
    height: 100% !important;
    padding: 0 !important;
    text-align: center !important;
}

.wc-block-components-quantity-selector button {
    background: #ffffff !important;
    border-radius: 50% !important;
    width: 34px !important;
    height: 34px !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important;
    color: #6c757d !important;
    font-size: 1.2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 2px !important;
    border: none !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
}

.wc-block-components-quantity-selector button:hover {
    background: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 4px 10px rgba(90, 111, 220, 0.2) !important;
}

/* Remove Button - Change from Text to Red Icon */
.wc-block-cart-item__remove-link,
button.wc-block-cart-item__remove-link {
    font-size: 0 !important; /* Hide the text */
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    height: 42px !important;
    background: #fff1f2 !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    border: none !important;
    color: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}

.wc-block-cart-item__remove-link::before,
button.wc-block-cart-item__remove-link::before {
    content: '\f2ed'; /* FontAwesome Trash-alt */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 1.2rem !important;
    color: #e11d48 !important;
    visibility: visible !important;
    transition: all 0.3s ease !important;
    display: block !important;
}

.wc-block-cart-item__remove-link:hover,
button.wc-block-cart-item__remove-link:hover {
    background: #e11d48 !important;
    transform: scale(1.05) !important;
}

.wc-block-cart-item__remove-link:hover::before,
button.wc-block-cart-item__remove-link:hover::before {
    color: #ffffff !important;
}

.wc-block-cart-item__total,
.wc-block-cart-item__totals {
    grid-column: 3 !important;
    grid-row: 1 !important; /* Placed explicitly in Row 1 */
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    text-align: left !important;
    border: none !important;
    padding: 0 !important;
}

/* Responsive Fixes */
@media (max-width: 768px) {
    .wc-block-cart-item__wrap {
        grid-template-columns: 80px 1fr !important; /* Price moves to next row */
        grid-template-rows: auto auto auto !important;
        gap: 10px 15px !important;
    }
    
    .wc-block-cart-item__total,
    .wc-block-cart-item__totals {
        grid-column: 1 / span 2 !important;
        grid-row: 3 !important;
        justify-content: space-between !important;
        padding-top: 10px !important;
        border-top: 1px dashed #eef0fb !important;
    }
}


/* Cart Totals Box */
.wc-block-cart__totals {
    background: #ffffff !important;
    border-radius: 20px !important;
    padding: 35px !important;
    box-shadow: 0 15px 50px rgba(90, 111, 220, 0.08) !important;
    border: 1px solid rgba(90, 111, 220, 0.1) !important;
    position: sticky !important;
    top: 155px !important;
    z-index: 10 !important;
    align-self: flex-start !important;
}

.wc-block-cart__totals-title {
    font-weight: 900 !important;
    font-size: 1.4rem !important;
    color: var(--secondary-color) !important;
    border-bottom: 2px dashed #eef0fb !important;
    padding-bottom: 20px !important;
    margin-bottom: 25px !important;
}

/* Subtotals and Totals rows */
.wc-block-components-totals-item {
    margin-bottom: 15px !important;
}

.wc-block-components-totals-item__label {
    font-weight: 600 !important;
    color: #6c757d !important;
}

.wc-block-components-totals-item__value {
    font-weight: 800 !important;
    color: var(--secondary-color) !important;
}

.wc-block-components-totals-footer-item {
    border-top: 1px solid #eef0fb !important;
    padding-top: 25px !important;
    margin-top: 10px !important;
}

.wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
    font-size: 1.2rem !important;
    font-weight: 900 !important;
    color: var(--secondary-color) !important;
}

.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    font-size: 1.4rem !important;
    font-weight: 900 !important;
    color: var(--primary-color) !important;
}

/* Proceed to Checkout Button */
.wc-block-cart__submit-button {
    margin-top: 30px !important;
    padding: 18px 20px !important;
    font-size: 1.2rem !important;
    border-radius: 15px !important;
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.3) !important;
}

.wc-block-cart__submit-button:hover {
    box-shadow: 0 15px 35px rgba(124, 58, 237, 0.4) !important;
    transform: translateY(-3px) !important;
}