/* =============================================================
   GIFTTREE BD — CART PAGE
   Cart-specific styles. Loaded only on is_cart().
   ============================================================= */

/* =============================================================
   WC NOTICES
   ============================================================= */
.cart-page .woocommerce-message,
.cart-page .woocommerce-info,
.cart-page .woocommerce-error {
    padding: 13px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 20px;
    list-style: none;
}
.cart-page .woocommerce-message { background: #edfadf; border: 1px solid #b4e282; color: #326e14; }
.cart-page .woocommerce-info    { background: #eef6ff; border: 1px solid #93c5fd; color: #1d4ed8; }
.cart-page .woocommerce-error   { background: #fff1f0; border: 1px solid #fca5a5; color: #b91c1c; }
.cart-page .woocommerce-error li { list-style: none; }

/* =============================================================
   PAGE HEADER
   ============================================================= */
.cart-page-header {
    background: var(--color-blush);
    padding: 36px 0 28px;
    border-bottom: 1px solid var(--color-border);
}

.cart-page-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3.5vw, 2.25rem);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 6px;
    line-height: 1.2;
}

.cart-page-subtitle {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin: 0 0 12px;
}

/* =============================================================
   PAGE BODY
   ============================================================= */
.cart-page-body {
    padding-top: 32px;
    padding-bottom: 72px;
}

/* =============================================================
   DELIVERY BANNER
   ============================================================= */
.cart-delivery-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #edfadf;
    border: 1px solid #b4e282;
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-bottom: 28px;
    font-size: 0.85rem;
    color: #326e14;
    line-height: 1.5;
}

.cart-delivery-banner svg { flex-shrink: 0; }

/* =============================================================
   CART LAYOUT — 2-COLUMN GRID
   Columns: items  | summary
   ============================================================= */
.cart-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 28px;
    align-items: start;
}

.cart-col-items  { min-width: 0; }

.cart-col-summary {
    position: sticky;
    top: 112px;
}

/* =============================================================
   ITEM GRID — shared column template
   72px thumb | 1fr info | 84px price | 116px qty | 84px subtotal | 32px remove
   Both .cart-header-row and .cart-item-row use the SAME grid.
   ============================================================= */
:root {
    --cart-cols: 72px minmax(0, 1fr) 84px 116px 84px 32px;
    --cart-gap: 14px;
}

/* =============================================================
   COLUMN HEADERS (desktop only)
   ============================================================= */
.cart-header-row {
    display: grid;
    grid-template-columns: var(--cart-cols);
    column-gap: var(--cart-gap);
    padding: 0 18px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.chr-blank    { /* placeholder cell */ }
.chr-product  { /* product name column */ }
.chr-price    { text-align: right; }
.chr-qty      { text-align: center; }
.chr-subtotal { text-align: right; }

/* =============================================================
   CART ITEMS LIST
   ============================================================= */
.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

/* Loading state */
.cart-items-list.cart-is-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* =============================================================
   CART ITEM ROW
   6-column CSS grid — SAME columns as .cart-header-row
   ============================================================= */
.cart-item-row {
    display: grid;
    grid-template-columns: var(--cart-cols);
    column-gap: var(--cart-gap);
    align-items: center;
    padding: 14px 18px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: box-shadow 0.18s ease;
}

.cart-item-row:hover {
    box-shadow: var(--shadow-sm);
}

/* ── col 1: Thumbnail ── */
.cart-item-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-blush);
}

.cart-item-thumb a { display: block; width: 100%; height: 100%; }

.cart-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── col 2: Product info ── */
.cart-item-info { min-width: 0; }

.cart-item-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    line-height: 1.45;
    margin-bottom: 4px;
    word-break: break-word;
    transition: color 0.15s;
}

a.cart-item-name:hover { color: var(--color-primary); }

.cart-item-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-item-meta span {
    font-size: 0.75rem;
    color: var(--color-muted);
    line-height: 1.4;
}

/* ── col 3: Unit price ── */
.cart-item-price {
    text-align: right;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* ── col 4: Qty stepper ── */
.cart-item-qty {
    display: flex;
    justify-content: center;
}

.cart-qty-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--color-white);
    height: 36px;
}

.cqs-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-family: var(--font-body);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.cqs-btn:hover:not(:disabled) {
    background: var(--color-blush);
    color: var(--color-primary);
}

.cqs-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.cqs-input {
    width: 38px;
    border: none;
    border-left: 1.5px solid var(--color-border);
    border-right: 1.5px solid var(--color-border);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-white);
    padding: 0;
    outline: none;
    -moz-appearance: textfield;
}

.cqs-input::-webkit-inner-spin-button,
.cqs-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.cqs-input:focus { background: var(--color-cream); }

/* ── col 5: Row subtotal ── */
.cart-item-subtotal {
    text-align: right;
    font-size: 0.925rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* ── col 6: Remove ── */
.cart-item-remove {
    display: flex;
    justify-content: center;
}

.cart-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--color-border);
    color: var(--color-muted);
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cart-remove-btn:hover {
    background: #fff0ee;
    border-color: #e05c4a;
    color: #e05c4a;
}

/* =============================================================
   CART ACTIONS ROW
   ============================================================= */
.cart-actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.cart-continue-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.875rem;
    border-radius: var(--radius-pill);
    padding: 9px 20px;
}

/* =============================================================
   COUPON
   ============================================================= */
.cart-coupon-wrap {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cart-coupon-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 13px 18px;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--color-muted);
    cursor: pointer;
    transition: color 0.15s;
}

.cart-coupon-toggle:hover { color: var(--color-primary); }

.cart-coupon-toggle-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-coupon-chevron { transition: transform 0.2s ease; flex-shrink: 0; }

.cart-coupon-toggle[aria-expanded="true"] .cart-coupon-chevron {
    transform: rotate(180deg);
}

.cart-coupon-panel {
    padding: 16px 18px;
    border-top: 1px solid var(--color-border);
    background: var(--color-cream);
}

.cart-coupon-fields {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.cart-coupon-input { flex: 1; min-width: 0; }

.cart-coupon-apply {
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    padding: 10px 20px;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* =============================================================
   ORDER SUMMARY CARD
   ============================================================= */
.order-summary-card {
    background: var(--color-white);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 26px 22px;
    box-shadow: var(--shadow-sm);
}

.order-summary-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--color-primary);
    /* Override global h2 clamp */
    line-height: 1.3;
}

.order-summary-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}

.order-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.order-row--discount { color: var(--color-primary-dark); font-weight: 500; }
.order-row--discount a.woocommerce-remove-coupon { opacity: 0.55; margin-left: 4px; }
.order-row--discount a.woocommerce-remove-coupon:hover { opacity: 1; color: #e05c4a; }

.order-row--total {
    padding-top: 14px;
    border-top: 1.5px solid var(--color-border);
    font-size: 1rem;
    color: var(--color-text);
    align-items: center;
}

.order-delivery-calc {
    font-size: 0.78rem;
    font-style: italic;
    text-align: right;
}

.order-total-amount {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--color-text);
}

.order-checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    padding: 14px 20px;
}

.order-secure-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.77rem;
    color: var(--color-muted);
    margin: 0 0 16px;
}

.order-payment-badges {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* =============================================================
   EMPTY STATE
   ============================================================= */
.cart-empty-state {
    text-align: center;
    padding: 80px 20px;
    max-width: 400px;
    margin: 0 auto;
}

.cart-empty-icon { margin-bottom: 24px; }

.cart-empty-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    margin: 0 0 10px;
    color: var(--color-text);
}

.cart-empty-text {
    font-size: 0.95rem;
    color: var(--color-muted);
    margin: 0 0 28px;
    line-height: 1.6;
}

/* =============================================================
   RESPONSIVE — MEDIUM DESKTOP (≤ 1100px)
   Tighten the item columns so "info" stays readable
   ============================================================= */
@media (max-width: 1100px) {
    :root {
        --cart-cols: 68px minmax(0, 1fr) 76px 108px 76px 28px;
        --cart-gap: 12px;
    }

    .cart-layout {
        grid-template-columns: 1fr 320px;
        gap: 22px;
    }

    .cart-item-thumb { width: 68px; height: 68px; }
}

/* =============================================================
   RESPONSIVE — TABLET (≤ 900px)
   Even tighter columns
   ============================================================= */
@media (max-width: 900px) {
    :root {
        --cart-cols: 64px minmax(0, 1fr) 70px 100px 70px 28px;
        --cart-gap: 10px;
    }

    .cart-layout {
        grid-template-columns: 1fr 290px;
        gap: 18px;
    }

    .cart-item-thumb { width: 64px; height: 64px; }
    .cart-item-row   { padding: 12px 16px; }
    .cart-header-row { padding: 0 16px 8px; }
}

/* =============================================================
   RESPONSIVE — STACKED LAYOUT (≤ 768px)
   Summary drops below items.
   Item rows use grid-template-areas: 2-row layout.
   ============================================================= */
@media (max-width: 768px) {

    .cart-page-header { padding: 24px 0 20px; }
    .cart-page-body   { padding-top: 20px; padding-bottom: 48px; }

    /* Stack the 2-column layout */
    .cart-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .cart-col-summary { position: static; }

    /* Hide desktop column headers */
    .cart-header-row { display: none; }

    /* ── ITEM ROW: switch to 2-row grid-template-areas ── */
    :root {
        --cart-cols: unset;
        --cart-gap: unset;
    }

    .cart-item-row {
        display: grid;
        grid-template-columns: 64px minmax(0, 1fr) 28px;
        grid-template-rows: auto auto;
        grid-template-areas:
            "thumb  info    remove"
            "thumb  bottom  bottom";
        column-gap: 12px;
        row-gap: 10px;
        align-items: start;
        padding: 14px 14px;
    }

    .cart-item-thumb    { grid-area: thumb; width: 64px; height: 64px; }
    .cart-item-info     { grid-area: info;  align-self: center; }
    .cart-item-remove   { grid-area: remove; align-self: start; justify-self: center; margin-top: 2px; }

    /* The price / qty / subtotal sit in a flex row on the second line */
    .cart-item-price,
    .cart-item-qty,
    .cart-item-subtotal {
        grid-area: bottom;
    }

    /* Group them into a flex row — all three share the same area,
       which means only the LAST one by DOM order would normally show.
       We solve this by wrapping them in a sub-grid row using display:contents trick. */

    /* Actually, since they're 3 separate elements, they can't all share one area.
       Solution: put them in a wrapper. Since cart.php has them as separate children,
       we use a CSS trick: give each a different area and define 3 bottom columns. */

    .cart-item-row {
        grid-template-columns: 64px minmax(0, 1fr) 28px;
        grid-template-rows: auto auto;
        grid-template-areas:
            "thumb info    remove"
            "price qty     subtotal";
    }

    .cart-item-thumb    { grid-area: thumb; width: 64px; height: 64px; align-self: start; }
    .cart-item-info     { grid-area: info;  }
    .cart-item-remove   { grid-area: remove; align-self: start; justify-self: center; }
    .cart-item-price    { grid-area: price;    font-size: 0.8rem;  text-align: left; }
    .cart-item-qty      { grid-area: qty;      justify-content: center; }
    .cart-item-subtotal { grid-area: subtotal; font-size: 0.875rem; text-align: right; }
}

/* =============================================================
   RESPONSIVE — SMALL MOBILE (≤ 480px)
   ============================================================= */
@media (max-width: 480px) {

    .cart-delivery-banner { font-size: 0.8rem; }

    .cart-item-row {
        grid-template-columns: 60px minmax(0, 1fr) 28px;
        padding: 12px 12px;
        column-gap: 10px;
        row-gap: 8px;
    }

    .cart-item-thumb { width: 60px; height: 60px; }

    .cart-item-name { font-size: 0.82rem; }

    /* Compact stepper */
    .cart-qty-stepper { height: 32px; }
    .cqs-btn   { width: 26px; font-size: 0.9rem; }
    .cqs-input { width: 32px; font-size: 0.82rem; }

    .cart-coupon-fields { flex-direction: column; }
    .cart-coupon-apply  { align-self: flex-start; }

    .order-summary-card { padding: 18px 16px; }
}

/* =============================================================
   RESPONSIVE — TINY PHONES (≤ 360px)
   ============================================================= */
@media (max-width: 360px) {

    .cart-item-row {
        grid-template-columns: 56px minmax(0, 1fr) 26px;
        padding: 10px;
        column-gap: 8px;
    }

    .cart-item-thumb { width: 56px; height: 56px; }

    .cart-item-subtotal { font-size: 0.82rem; }
}
