/* =========================================
   Mobile Cart & Checkout Responsiveness Fixes
   ========================================= */

@media (max-width: 767.98px) {
    /* --- Cart Page --- */

    /* Hide the desktop header row */
    .cart-header-row {
        display: none !important;
    }

    /* Redesign main cart row to match sticky cart compact card */
    .cart-item-row {
        display: grid !important;
        grid-template-columns: 45px 1fr 60px !important;
        grid-template-areas:
            "img title total"
            "img qty delete" !important;
        gap: 6px !important;
        padding: 8px !important;
        align-items: center !important;
        height: auto !important;
        position: relative !important;
        flex-wrap: nowrap !important;
        /* overide flex */
    }

    .cart-item-row>div:nth-child(1) {
        grid-area: img;
        flex: unset !important;
    }

    .cart-item-row>div:nth-child(2) {
        grid-area: title;
        font-size: 0.93rem !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        text-align: left !important;
        flex: unset !important;
        max-width: 100% !important;
    }

    .cart-item-row>div:nth-child(3) {
        display: none !important;
    }

    /* MRP */
    .cart-item-row>div:nth-child(4) {
        display: none !important;
    }

    /* You Pay */
    .cart-item-row>div:nth-child(5) {
        display: none !important;
    }

    /* Savings */

    .cart-item-row>div:nth-child(6) {
        grid-area: qty;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        flex: unset !important;
    }

    .cart-item-row>div:nth-child(7) {
        grid-area: total;
        text-align: right !important;
        font-weight: 700 !important;
        font-size: 0.95rem !important;
        align-self: start !important;
        padding-top: 4px !important;
        flex: unset !important;
        display: block !important;
        /* make sure visible */
    }

    .cart-item-row>div:nth-child(8) {
        grid-area: delete;
        text-align: right !important;
        align-self: end !important;
        flex: unset !important;
        position: static !important;
        /* override absolute */
    }

    /* Stack checkout summary */
    .shopping-card .card-body {
        padding: 15px;
    }

    /* Increase font size and weight of Cart & Price Summary Headers on Mobile */
    .shopping-card .card-header h5 {
        font-size: 1.05rem !important;
        font-weight: 600 !important;
    }

    /* --- Checkout Page --- */

    /* Address Actions Buttons */
    .address-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .address-actions .btn {
        flex: 1 1 auto;
        margin-right: 0;
        margin-bottom: 5px;
        text-align: center;
        padding: 6px 10px;
    }

    /* Payment Method Radio Labels */
    .form-check-label {
        padding: 12px;
    }

    /* Place Order Button */
    .place-order-btn {
        padding: 12px;
        font-size: 1.1rem;
        border: none !important;
        /* Request 4: Remove blue border */
        box-shadow: none !important;
    }

    /* Add Address Form inputs */
    #addAddressForm .col-md-6,
    #addAddressForm .col-md-4,
    #addAddressForm .col-md-8,
    #addAddressForm .col-md-12 {
        margin-bottom: 10px;
    }

    .checkout-card {
        margin-bottom: 8px !important;
        /* Phase 4: Reduce card margin */
    }

    /* --- Checkout Page Refinements --- */
    .container.my-5 {
        margin-top: 10px !important;
        /* Phase 4: Reduce top margin */
        margin-bottom: 10px !important;
    }

    .row.g-4 {
        --bs-gutter-x: 10px !important;
        --bs-gutter-y: 0px !important;
        /* Phase 4: Remove vertical gutter between columns */
    }

    .checkout-card .card-body {
        padding: 12px !important;
    }

    /* Request 2: Align Bill Summary card with Address section */
    .col-lg-4 form>.checkout-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Phase 4: Aggressive pull-up for the summary column */
    .col-lg-4 {
        margin-top: -20px !important;
    }

    /* Headings font size increase */
    .checkout-card h5 {
        font-size: 1.05rem !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
    }

    /* Request 1: Bill Summary Header standardization */
    .checkout-card h5 span {
        color: inherit !important;
        font-weight: inherit !important;
        font-size: inherit !important;
    }

    .checkout-card h6 {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
        margin-bottom: 10px !important;
    }

    /* Bill Summary details font size increase */
    .checkout-card .d-flex.justify-content-between.mb-2 {
        font-size: 1.05rem !important;
        margin-bottom: 10px !important;
    }

    .checkout-card .d-flex.justify-content-between.mb-2 span:last-child {
        font-weight: 600 !important;
    }

    /* Total amount font size */
    #order-total-amount {
        font-size: 1rem !important;
    }

    /* Savings rectangle alignment and styling */
    .checkout-card .bg-light.p-2.rounded {
        margin-left: -12px !important;
        margin-right: -12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        border-radius: 0 !important; /* Make it full width of card */
    }

    /* Total Amount to Pay rectangle alignment */
    .checkout-card .bg-primary.bg-opacity-10.p-2.rounded {
        margin-left: -12px !important;
        margin-right: -12px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        border-radius: 0 !important;
    }

    /* Request 3 & Phase 3: Back to Cart Button refinements */
    .back-to-cart-wrapper {
        margin-top: 0 !important;
    }

    .back-to-cart-btn {
        padding: 8px 16px !important;
    }

    /* Request 5 & Phase 4: Absolute minimal space above summary components */
    .col-lg-4 form>.checkout-card:first-child {
        margin-top: 0 !important;
    }

    /* Phase 3 & 5: Payment section spacing adjustments */
    .checkout-card.mt-3 {
        margin-top: 5px !important;
        /* Reduce mt-3 override */
    }

    .checkout-card h6.mb-2 {
        font-size: 1.05rem !important;
        font-weight: 600 !important;
        margin-top: 0 !important;
        /* Phase 5: Minimal top space */
    }

    .checkout-card.mt-3 .card-body {
        padding-top: 2px !important;
        /* Phase 5: 2px top gap inside card */
    }

    /* Phase 3: Explicit spacing reductions */
    .gst-section-wrapper {
        margin-bottom: 0 !important;
        margin-top: 10px !important;
    }

    .place-order-wrapper {
        margin-bottom: 0 !important;
    }
}