/**
 * Cart page (F36) — custom server-side cart UI.
 *
 * Brand colors:
 *   --cv-green-dark:   #497D59
 *   --cv-green-mid:    #9CC069
 *   --cv-green-light:  #DBEAC6
 *   --cv-gold:         #F6C531
 *
 * Layout: 2-column grid (cart items left, sticky summary right) on desktop,
 * stacked on mobile. Bundle cards group items by delivery day.
 */

:root {
    --cv-green-dark:  #497D59;
    --cv-green-mid:   #9CC069;
    --cv-green-light: #DBEAC6;
    --cv-gold:        #F6C531;
    --cv-text:        #2c2c2c;
    --cv-text-muted:  #6b6b6b;
    --cv-border:      #e3e3e3;
    --cv-bg-card:     #ffffff;
    --cv-bg-page:     #f7f8f5;
    --cv-radius:      12px;
    --cv-shadow:      0 2px 6px rgba(0, 0, 0, 0.04);
    --cv-shadow-lg:   0 4px 18px rgba(0, 0, 0, 0.08);
}

/* ───── Layout ───── */

.cv-cart-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-areas: "main summary";
    gap: 32px;
    align-items: start;
    max-width: 1240px;
    margin: 32px auto 0;
    padding: 0 24px;
    color: var(--cv-text);
    font-family: 'Open Sans', sans-serif;
}

.cv-cart-main { grid-area: main; }
.cv-cart-summary { grid-area: summary; }

.cv-cart-upsell-wrap {
    /* Rendered as sibling of .cv-cart-page (NOT inside the grid). The summary
     * sticky's containing block is the grid, which ends with the bundles row
     * — this sibling layout means the summary releases sticky exactly where
     * the upsell begins, with no overlap. */
    max-width: 1240px;
    margin: 12px auto 64px;
    padding: 0 24px;
}

.cv-cart-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.cv-cart-summary {
    position: sticky;
    top: 100px;
    align-self: start;
}

/* Kava parent theme sets `overflow: hidden` on `.site` (its outermost wrapper)
 * to clip horizontal-overflow Elementor sections. That creates a new scroll
 * container which disables `position: sticky` for descendants. Scoped override
 * for the cart page only — there are no full-bleed Elementor sections on
 * /cart/, so unclipping `.site` is safe and lets the summary stick. */
body.woocommerce-cart .site {
    overflow: visible;
}

@media (max-width: 900px) {
    .cv-cart-page {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "summary";
        gap: 20px;
        margin-top: 16px;
        padding: 0 16px;
    }
    .cv-cart-summary {
        position: static;
    }
    .cv-cart-upsell-wrap {
        padding: 0 16px;
        margin-bottom: 32px;
    }
}

/* ───── Empty state ───── */

.cv-cart-empty {
    text-align: center;
    padding: 80px 24px;
    background: var(--cv-bg-card);
    border-radius: var(--cv-radius);
    border: 1px solid var(--cv-border);
    margin: 32px auto;
    max-width: 720px;
}

.cv-cart-empty h2 {
    color: var(--cv-green-dark);
    margin: 0 0 12px;
    font-size: 28px;
}

.cv-cart-empty p {
    color: var(--cv-text-muted);
    margin: 0 0 24px;
}

/* ───── Buttons ───── */

.cv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.2;
    font-family: inherit;
}

.cv-btn-primary {
    background: var(--cv-green-dark);
    color: #ffffff;
}
.cv-btn-primary:hover {
    background: #3d6a4b;
    color: #ffffff;
}

.cv-btn-secondary {
    background: #ffffff;
    color: var(--cv-green-dark);
    border-color: var(--cv-green-dark);
}
.cv-btn-secondary:hover {
    background: var(--cv-green-light);
}

/* ───── Bundle card ───── */

.cv-cart-bundle-card {
    background: var(--cv-bg-card);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    padding: 0;
    box-shadow: var(--cv-shadow);
    overflow: hidden;
    position: relative;
}

.cv-cart-bundle-card.is-incomplete {
    border-color: #e6c45a;
    box-shadow: 0 0 0 1px rgba(246, 197, 49, 0.18), var(--cv-shadow);
}

.cv-cart-bundle-card.is-complete {
    border-color: var(--cv-green-mid);
}

.cv-cart-bundle-card.is-complete::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--cv-green-dark), var(--cv-green-mid));
}

.cv-cart-bundle-card.is-incomplete::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--cv-gold);
}

/* ───── Bundle header ───── */

.cv-cart-bundle-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    background: linear-gradient(180deg, #fbfdfa 0%, #ffffff 100%);
    border-bottom: 1px solid var(--cv-border);
    flex-wrap: wrap;
}

.cv-cart-bundle-card__title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.cv-cart-bundle-card__title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--cv-green-dark);
    white-space: nowrap;
}

.cv-cart-bundle-card__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--cv-green-light);
    color: var(--cv-green-dark);
    font-weight: 700;
}
.is-complete .cv-cart-bundle-card__badge {
    background: var(--cv-green-mid);
    color: #ffffff;
}
.is-incomplete .cv-cart-bundle-card__badge {
    background: var(--cv-gold);
    color: #ffffff;
}

.cv-cart-bundle-card__check,
.cv-cart-bundle-card__warn {
    font-size: 14px;
    line-height: 1;
}

.cv-cart-bundle-card__progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--cv-text-muted);
}

.cv-cart-bundle-card__progress-item {
    padding: 2px 10px;
    border-radius: 999px;
    background: #f1f4ee;
    font-weight: 600;
}
.cv-cart-bundle-card__progress-item.is-done {
    background: var(--cv-green-light);
    color: var(--cv-green-dark);
}

.cv-cart-bundle-card__actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.cv-cart-page .cv-cart-bundle-card__edit,
.cv-cart-page .cv-cart-bundle-card__remove {
    background: transparent !important;
    border: 0 !important;
    color: var(--cv-green-dark) !important;
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px !important;
    min-height: 0 !important;
    min-width: 0 !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-family: inherit;
    box-shadow: none !important;
}
.cv-cart-page .cv-cart-bundle-card__edit:hover,
.cv-cart-page .cv-cart-bundle-card__remove:hover {
    background: var(--cv-green-light) !important;
}

.cv-cart-page .cv-cart-bundle-card__remove {
    color: #b04545 !important;
}
.cv-cart-page .cv-cart-bundle-card__remove:hover {
    background: #fbe9e9 !important;
}

/* Incomplete-bundle warning row inside the card */

.cv-cart-bundle-card__incomplete-note {
    margin: 0;
    padding: 10px 22px;
    background: #fff7e0;
    color: #6b4f0a;
    font-size: 13px;
    border-bottom: 1px solid #f1e3b5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.cv-cart-bundle-card__incomplete-note a {
    color: var(--cv-green-dark);
    font-weight: 700;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--cv-green-dark);
    padding: 4px 12px;
    border-radius: 999px;
    transition: background 0.12s ease;
    white-space: nowrap;
}
.cv-cart-bundle-card__incomplete-note a:hover {
    background: var(--cv-green-light);
}

/* ───── Day section inside bundle ───── */

.cv-cart-day-section {
    padding: 8px 22px 4px;
    border-bottom: 1px solid #f1f1f1;
}
.cv-cart-day-section:last-of-type {
    border-bottom: 0;
}

.cv-cart-day-section__title {
    margin: 14px 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--cv-text);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.cv-cart-day-section__icon {
    font-size: 16px;
}

.cv-cart-day-section__count {
    font-weight: 500;
    color: var(--cv-text-muted);
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}

.cv-cart-day-section__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cv-cart-day-section__empty {
    color: var(--cv-text-muted);
    padding: 14px 0;
    font-style: italic;
    font-size: 13px;
}

/* ───── Item row ───── */

.cv-cart-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f4f4f4;
    position: relative;
    padding-right: 32px;
}
.cv-cart-item:last-child {
    border-bottom: 0;
}

.cv-cart-item__image img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.cv-cart-item__body {
    min-width: 0;
}

.cv-cart-item__name {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--cv-text);
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.cv-cart-item__variation {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--cv-text-muted);
}
.cv-cart-item__variation li span {
    color: var(--cv-text);
    font-weight: 600;
}

.cv-cart-item__qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--cv-border);
    border-radius: 999px;
    overflow: hidden;
    background: #fbfbfb;
}
/* Overrides for theme/Elementor button backgrounds that bleed in.
 * Qty pill: 28px buttons + 50px input = 106px total. Owner-reported the
 * previous 24px input was too narrow to show a single digit (number got
 * cut off). 50px gives comfortable room for 1-3 digits while keeping the
 * cart-item grid balanced. */
.cv-cart-page .cv-cart-item__qty button,
.cv-cart-page .cv-cart-item__qty .cv-cart-item__qty-dec,
.cv-cart-page .cv-cart-item__qty .cv-cart-item__qty-inc {
    background: transparent !important;
    border: 0 !important;
    width: 28px !important;
    height: 32px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 28px !important;
    padding: 0 !important;
    font-size: 14px !important;
    color: var(--cv-green-dark) !important;
    font-weight: 700;
    cursor: pointer;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.cv-cart-page .cv-cart-item__qty button:hover {
    background: var(--cv-green-light) !important;
}
.cv-cart-item__qty-input {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--cv-text);
    line-height: 32px;
    -moz-appearance: textfield;
    appearance: textfield;
}
.cv-cart-item__qty-input::-webkit-inner-spin-button,
.cv-cart-item__qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cv-cart-item__price {
    font-weight: 700;
    color: var(--cv-text);
    min-width: 70px;
    text-align: right;
}

.cv-cart-page .cv-cart-item__remove {
    background: transparent !important;
    border: 0 !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    color: #b04545 !important;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 4px;
    line-height: 1;
    box-shadow: none !important;
}
.cv-cart-page .cv-cart-item__remove:hover {
    background: #fbe9e9 !important;
}

@media (max-width: 600px) {
    .cv-cart-item {
        grid-template-columns: 56px 1fr auto;
        grid-template-areas:
            "image body remove"
            "qty   qty  price";
        row-gap: 8px;
    }
    .cv-cart-item__image { grid-area: image; }
    .cv-cart-item__body  { grid-area: body; }
    .cv-cart-item__remove{ grid-area: remove; align-self: start; }
    .cv-cart-item__qty   { grid-area: qty; justify-self: start; }
    .cv-cart-item__price { grid-area: price; text-align: right; }
}

/* ───── Mobile bundle header (≤540) — stack title chips above the
 *       Edit/Remove actions so nothing overlaps at narrow widths ───── */
@media (max-width: 540px) {
    .cv-cart-bundle-card__header {
        padding: 14px 16px;
        gap: 8px 10px;
    }
    .cv-cart-bundle-card__title h3 {
        font-size: 16px;
    }
    .cv-cart-bundle-card__actions {
        width: 100%;
        justify-content: flex-end;
        border-top: 1px dashed var(--cv-border);
        padding-top: 8px;
    }
    .cv-cart-bundle-card__incomplete-note {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .cv-cart-alacarte__list,
    .cv-cart-bundle-card__day-section {
        padding: 8px 14px 12px;
    }
    .cv-cart-bundle-card__footer {
        padding: 12px 16px;
    }
    /* Item row: tighter image + remove gutter so the title column has room
     * for "Coconut Chicken Curry" on a single line at 375 viewports. */
    .cv-cart-item {
        grid-template-columns: 48px 1fr auto;
        gap: 10px;
        padding: 10px 0;
        padding-right: 28px;
    }
    .cv-cart-item__image img {
        width: 48px;
        height: 48px;
    }
    .cv-cart-item__name {
        font-size: 14px;
    }
    /* Variation list (Protein / Side / Size) repeats the same Regular/Adult
     * defaults across virtually every meal — at narrow widths it wraps to 3+
     * lines and bloats every row without adding scannable info. Hide on
     * mobile; full detail still surfaces on /checkout/ + /view-order/. */
    .cv-cart-item__variation {
        display: none;
    }
    .cv-cart-item__remove {
        right: 0 !important;
    }
    .cv-cart-item__price {
        font-size: 14px;
    }
}

/* ───── Bundle card footer (subtotal) ───── */

.cv-cart-bundle-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 22px;
    background: #fbfdfa;
    border-top: 1px solid var(--cv-border);
    font-size: 14px;
}

.cv-cart-bundle-card__subtotal-label {
    color: var(--cv-text-muted);
    font-weight: 500;
}

.cv-cart-bundle-card__subtotal-value {
    font-weight: 700;
    color: var(--cv-text);
    font-size: 16px;
}

/* ───── À la carte card variant ───── */

.cv-cart-alacarte-card .cv-cart-bundle-card__header {
    background: linear-gradient(180deg, #fff8e6 0%, #ffffff 100%);
}
.cv-cart-alacarte-card .cv-cart-bundle-card__badge {
    background: var(--cv-gold);
    color: #ffffff;
}
.cv-cart-alacarte-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--cv-gold);
}
.cv-cart-alacarte__list {
    list-style: none;
    margin: 0;
    padding: 12px 22px;
}
.cv-cart-alacarte__list .cv-cart-item {
    border-bottom: 1px solid #f4f4f4;
}
.cv-cart-alacarte__list .cv-cart-item:last-child {
    border-bottom: 0;
}

/* ───── Add another plan dropdown ───── */

.cv-cart-add-another {
    position: relative;
    margin-top: 8px;
    align-self: flex-start;
    max-width: 320px;
    width: 100%;
}

.cv-cart-add-another__toggle {
    width: 100%;
    justify-content: center;
}

.cv-cart-add-another__caret {
    transition: transform 0.15s ease;
}
.cv-cart-add-another.is-open .cv-cart-add-another__caret {
    transform: rotate(180deg);
}

.cv-cart-add-another__menu {
    list-style: none;
    margin: 8px 0 0;
    padding: 8px;
    background: #ffffff;
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    box-shadow: var(--cv-shadow-lg);
    display: none;
    position: relative;
    z-index: 5;
}

.cv-cart-add-another.is-open .cv-cart-add-another__menu {
    display: block;
}

.cv-cart-add-another__menu li {
    margin: 0;
}

.cv-cart-add-another__menu a {
    display: block;
    padding: 12px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--cv-text);
    transition: background 0.12s ease;
}
.cv-cart-add-another__menu a:hover {
    background: var(--cv-green-light);
}
.cv-cart-add-another__menu strong {
    display: block;
    color: var(--cv-green-dark);
    margin-bottom: 2px;
    font-size: 14px;
}
.cv-cart-add-another__menu span {
    display: block;
    font-size: 12px;
    color: var(--cv-text-muted);
}

/* ───── Order summary sidebar ───── */

.cv-cart-summary__inner {
    background: var(--cv-bg-card);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    padding: 24px;
    box-shadow: var(--cv-shadow);
}

.cv-cart-summary__title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--cv-green-dark);
    border-bottom: 1px solid var(--cv-border);
    padding-bottom: 12px;
}

.cv-cart-summary__rows {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cv-cart-summary__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin: 0;
}
.cv-cart-summary__row dt {
    color: var(--cv-text-muted);
    font-weight: 500;
    margin: 0;
}
.cv-cart-summary__row dd {
    margin: 0;
    font-weight: 600;
    color: var(--cv-text);
}

.cv-cart-summary__row--discount dd {
    color: var(--cv-green-dark);
}

.cv-cart-summary__muted {
    color: var(--cv-text-muted);
    font-weight: 500;
    font-size: 12px;
}

.cv-cart-summary__total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid var(--cv-border);
    font-size: 14px;
}
.cv-cart-summary__total strong {
    font-size: 22px;
    color: var(--cv-green-dark);
}

.cv-cart-summary__note {
    margin: 12px 0 16px;
    font-size: 12px;
    color: var(--cv-text-muted);
    background: var(--cv-green-light);
    padding: 10px 12px;
    border-radius: 8px;
    line-height: 1.4;
}

.cv-cart-summary__checkout {
    width: 100%;
    padding: 14px 22px;
    font-size: 15px;
}

/* Center the discreet empty-cart link below the full-width Checkout CTA. */
.cv-cart-summary__inner > .cv-cart-empty-link {
    margin: 12px auto 0;
}


/* ───── Checkout-gate redirect notice ─────
 * Rendered ONCE at the top of /cart/ when the customer was bounced from
 * /checkout/ for not satisfying the purchase rules. One-shot — consumed by
 * the [cv_cart] shortcode from the WC session and never re-rendered until
 * the next gate redirect. */
.cv-cart-redirect-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 18px;
    padding: 14px 18px;
    background: #fdf8e6;
    border: 1px solid #F6C531;
    border-left: 4px solid #F6C531;
    border-radius: 12px;
    color: #8a6a08;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.cv-cart-redirect-notice__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #F6C531;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
}

.cv-cart-redirect-notice__body {
    flex: 1 1 auto;
    color: inherit;
    font-weight: 500;
}

@media (max-width: 540px) {
    .cv-cart-redirect-notice {
        padding: 12px 14px;
        font-size: 13px;
    }
}
