/* ===================================== */
/*  Desktop Flex Layout + Smooth Sticky Totals  */
/* ===================================== */
.cart-page-flex {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    font-family: 'DM Sans', sans-serif; /* Default font for all cart text */
}
.cart-products { flex: 0 0 65%; }
.cart-totals-wrapper { flex: 0 0 35%; position: relative; }

/* ===================================== */
/*  Cart Notices — GR1P flex layout      */
/*  Icon left, vertically centered       */
/* ===================================== */
.woocommerce-cart .woocommerce-message,
.woocommerce-cart .woocommerce-info {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.woocommerce-cart .woocommerce-error {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
}
.woocommerce-cart .woocommerce-message:before,
.woocommerce-cart .woocommerce-error:before,
.woocommerce-cart .woocommerce-info:before {
    flex: 0 0 auto;
    position: static;
    float: none;
    top: auto;
    margin: 0 10px 0 0;
}
.woocommerce-cart .woocommerce-message a.wc-forward,
.woocommerce-cart .woocommerce-message a.button {
    margin-left: auto;
}
@media (max-width: 767px) {
    .woocommerce-cart .woocommerce-message {
        flex-wrap: wrap;
    }
    .woocommerce-cart .woocommerce-message a.wc-forward,
    .woocommerce-cart .woocommerce-message a.button {
        margin-left: 0;
        width: 100%;
    }
}

/* Remove old sticky, JS handles smooth floating (desktop only) */
@media(min-width: 1025px) {
    .cart-totals-modern {
        position: relative;
        top: auto;
        transition: top 0.3s ease;
    }
}

/* ===================================== */
/*  GR1P updating / locked state         */
/* ===================================== */
.gr1p-cart-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    background: #f7f7f7;
    color: #555;
    font-size: 14px;
}
.gr1p-cart-status::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid #bbb;
    border-top-color: #222;
    border-radius: 50%;
    animation: gr1p-cart-spin 0.7s linear infinite;
}
@keyframes gr1p-cart-spin {
    to { transform: rotate(360deg); }
}
.modern-cart.gr1p-cart-locked .quantity {
    opacity: 0.6;
}
.modern-cart.gr1p-cart-locked .quantity .plus,
.modern-cart.gr1p-cart-locked .quantity .minus,
.modern-cart.gr1p-cart-locked .quantity input.qty {
    cursor: not-allowed;
}

/* ===================================== */
/*  Desktop Table Styles                 */
/* ===================================== */
.modern-cart table.shop_table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 15px;
}
.modern-cart th, .modern-cart td {
    padding: 10px;
    vertical-align: middle;
    font-family: 'DM Sans', sans-serif; /* Table text in DM Sans */
}
.modern-cart table.shop_table tr {
    border: none; /* remove Porto row outlines */
}
.modern-cart thead th {
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 0 10px 14px;
    border-bottom: 1px solid #e8e8e8;
}
.modern-cart .product-name {
    font-weight: 600;
    color: #222;
}
.modern-cart .product-price .amount {
    color: #6c757d;
    font-weight: 500;
}
.modern-cart .product-subtotal .amount {
    font-weight: 700;
    color: #222;
    font-size: 16px;
}
.modern-cart th.product-price,
.modern-cart td.product-price,
.modern-cart th.product-subtotal,
.modern-cart td.product-subtotal {
    text-align: right;
}
.modern-cart th.product-quantity,
.modern-cart td.product-quantity {
    text-align: center;
}
.modern-cart .product-thumbnail img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
}

/* Remove button — full GR1P ownership */
.modern-cart .product-remove .remove,
.modern-cart .product-thumbnail .remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    color: #ff4d4d;
    background: transparent;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.modern-cart .product-remove .remove:hover,
.modern-cart .product-thumbnail .remove:hover {
    background: #fdf1f0;
    color: #c53030;
    transform: scale(1.05);
}
.modern-cart .product-remove .remove:focus-visible,
.modern-cart .product-thumbnail .remove:focus-visible {
    outline: 2px solid #222;
    outline-offset: 2px;
}

/* Remove button — left of product image, vertically centered */
.modern-cart td.product-thumbnail {
    display: flex;
    align-items: center;
    gap: 8px;
}
.modern-cart td.product-thumbnail > a:first-child {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
}
.modern-cart td.product-thumbnail .remove {
    order: 1;
    flex: 0 0 auto;
}

/* Quantity Component — unified connected control (minus/qty/plus) */
.modern-cart .quantity.buttons_added {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    font-family: 'DM Sans', sans-serif;
}
.modern-cart .quantity.buttons_added .minus,
.modern-cart .quantity.buttons_added .plus {
    background: #222;
    color: #fff;
    border: none;
    border-radius: 0;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease;
}
.modern-cart .quantity.buttons_added .plus {
    left: auto; /* remove Porto -1px overlap */
}
.modern-cart .quantity.buttons_added .minus:hover,
.modern-cart .quantity.buttons_added .plus:hover {
    background: #444;
    color: #fff;
}
.modern-cart .quantity.buttons_added .minus:focus-visible,
.modern-cart .quantity.buttons_added .plus:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px #fff;
}
.modern-cart .quantity.buttons_added input.qty {
    width: 50px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
    border-radius: 0;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.2s ease;
    appearance: textfield;
    -moz-appearance: textfield;
}
.modern-cart .quantity.buttons_added input.qty::-webkit-outer-spin-button,
.modern-cart .quantity.buttons_added input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.modern-cart .quantity.buttons_added input.qty:focus {
    background: #fafafa;
}
.modern-cart .quantity.buttons_added input.qty:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px #222;
}

/* Cart Actions */
.cart-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-family: var(--gr1p-font-alt); /* Keep heading font for buttons */
}
.cart-actions .button {
    padding: 10px 20px;
    border-radius: 6px;
    background: #222;
    color: #fff;
    border: none;
    cursor: pointer;
    font-family: var(--gr1p-font-alt); /* Buttons retain the alternate font */
    text-transform: uppercase;
}
.cart-actions .button:hover { background: #444; }

/* Coupon field styling */
.cart-actions .coupon {
    display: flex;
    gap: 10px;
}
.cart-actions .coupon input.input-text {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-family: 'DM Sans', sans-serif;
}
.cart-actions .coupon button.button {
    font-family: var(--gr1p-font-alt); /* Buttons retain the alternate font */
}

/* Cart Totals Card */
.cart-totals-modern {
    border: 1px solid #ddd;
    padding: 20px;
    border-radius: 12px;
    background: #f9f9f9;
    font-family: 'DM Sans', sans-serif;
}
.cart-totals-modern table { width: 100%; }
.cart-totals-modern h3 {
    font-family: 'DM Sans', sans-serif;
    text-transform: uppercase;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #222;
    margin: 0 0 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8e8e8;
}
.cart-totals-modern .order-total th,
.cart-totals-modern .order-total td {
    padding-top: 12px;
    border-top: 1px solid #e8e8e8;
}
.cart-totals-modern .order-total .amount {
    font-size: 20px;
    font-weight: 700;
    color: #222;
}
.cart-totals-modern .checkout-btn {
    display: block;
    width: 100%;
    margin-top: 15px;
    text-align: center;
    background: #222;
    color: #fff;
    padding: 12px 0;
    border-radius: 8px;
    text-transform: uppercase;
    font-weight: bold;
    font-family: var(--gr1p-font-alt); /* Keep heading font for buttons */
}
.cart-totals-modern .checkout-btn:hover { background: #444; }


/* CSS Extensions */
.shop-card.variant-swiper {
    height: auto;
}

.shop-card.variant-grid {
    display: flex;
    flex-direction: column;
}

.shop-card.variant-compact {
    display: flex;
    gap: 10px;
}

.shop-card.variant-compact .shop-meta {
    padding: 8px;
}

.shop-card.variant-compact .shop-title {
    font-size: 13px;
}


/* ===================================== */
/*  Tablet / Mobile — responsive table    */
/*  Same single DOM as desktop           */
/* ===================================== */
@media (max-width: 1024px) {

    /* Stack the layout */
    .cart-page-flex { flex-direction: column; align-items: stretch; }
    .cart-products { flex: 0 0 auto; width: 100%; }
    .cart-totals-wrapper { flex: 0 0 auto; width: 100%; margin-top: 20px; }

    /* Neutralize JS sticky offset at tablet widths */
    .cart_totals, .cart-totals-modern { position: static !important; top: auto !important; }

    /* Turn each row into a card */
    .gr1p-cart-table { border-spacing: 0 !important; }
    .gr1p-cart-table thead { display: none; }
    .gr1p-cart-table,
    .gr1p-cart-table tbody { display: block; width: 100%; }

    .gr1p-cart-table tr.cart_item {
        display: block;
        border: 1px solid #ddd;
        border-radius: 12px;
        padding: 15px;
        margin-bottom: 20px;
        background: #fff;
        font-family: 'DM Sans', sans-serif;
    }
    .gr1p-cart-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 6px 0;
        border: none;
        text-align: right;
    }
    .gr1p-cart-table td::before {
        content: attr(data-title);
        flex: 0 0 auto;
        font-weight: 600;
        color: #6c757d;
        text-align: left;
    }
    .gr1p-cart-table td.product-thumbnail {
        justify-content: flex-start;
        margin-bottom: 10px;
    }
    .gr1p-cart-table td.product-thumbnail::before { content: none; }
    .gr1p-cart-table td.product-name {
        font-weight: 700;
        color: #222;
    }
    .gr1p-cart-table td.product-subtotal .amount { font-size: 16px; }

    /* Coupon field full-width on tablet/mobile */
    .cart-actions .coupon {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .cart-actions .coupon input.input-text,
    .cart-actions .coupon button.button {
        width: 100%;
        border-radius: 6px;
        margin: 0;
    }

    /* Update Cart full width below coupon */
    .cart-actions .button.update-cart { width: 100%; }
}
