/*
 * Chef Veronica — Mini-cart drawer (header)
 *
 * Compact bundle-grouped layout for the JetBlocks slide-out cart drawer.
 * Reuses the visual language of /cart/ scaled down for a 400px-wide surface.
 * View-only — no qty controls, no edit pencil; remove × stays for parity with
 * standard ecommerce affordances.
 *
 * Two layout concerns are addressed here:
 *   1. Vertical density — items, headers, and gaps are all shrunk so a Plan 5
 *      + extras combo doesn't push the totals off-screen.
 *   2. Sticky footer — the JetBlocks drawer is `height:100vh` slide-out, but
 *      the SCSS only set `overflow-y:auto` on the legacy `.woocommerce-mini-cart`
 *      <ul>, which we replaced. We re-establish a flex column layout on
 *      `.jet-blocks-cart__list` so the items area scrolls and total+buttons
 *      stay pinned at the bottom.
 */

/* ───── Drawer-level flex layout: scroll items + sticky footer ───── */

.jet-blocks-cart__list {
    display: flex;
    flex-direction: column;
}

/* Pin the title and close button at the top (close is absolute already). */
.jet-blocks-cart__list-title {
    flex: 0 0 auto;
}

/* The widget wrapper added by `the_widget('WC_Widget_Cart')` plus the
 * fragment wrapper need to grow and become flex columns themselves so the
 * scroll boundary lives on `.cv-mini-cart`. */
.jet-blocks-cart__list .widget_shopping_cart,
.jet-blocks-cart__list .widget.woocommerce.widget_shopping_cart,
.jet-blocks-cart__list .widget_shopping_cart_content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;  /* let inner overflow trigger */
    margin: 0;
    padding: 0;
}

.jet-blocks-cart__list .cv-mini-cart {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    margin: 0 0 8px;
    padding-right: 4px; /* leave room for the scrollbar without clipping */
}

.jet-blocks-cart__list .woocommerce-mini-cart__total,
.jet-blocks-cart__list .woocommerce-mini-cart__buttons,
.jet-blocks-cart__list .cv-mini-cart__empty-row {
    flex: 0 0 auto;
    margin: 0;
}

/* Empty-cart row: minimal separator + tight padding so the discreet link
 * sits inside the sticky footer cluster without adding visual weight above
 * the total + Checkout buttons. */
.jet-blocks-cart__list .cv-mini-cart__empty-row {
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
}

/* Empty-cart message stays centered without flex stretch */
.jet-blocks-cart__list .woocommerce-mini-cart__empty-message {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Custom scrollbar matches JetBlocks defaults */
.jet-blocks-cart__list .cv-mini-cart::-webkit-scrollbar         { width: 6px; }
.jet-blocks-cart__list .cv-mini-cart::-webkit-scrollbar-thumb   { background-color: #d8d8d8; border-radius: 10px; }
.jet-blocks-cart__list .cv-mini-cart::-webkit-scrollbar-track   { background: transparent; }

/* ───── Scoped tokens (mirror cart-page.css) ───── */

.cv-mini-cart {
    --cv-green-dark:  #497D59;
    --cv-green-mid:   #9CC069;
    --cv-green-light: #DBEAC6;
    --cv-gold:        #F6C531;
    --cv-text-muted:  #6b6b6b;
    --cv-border:      #e3e3e3;
    --cv-bg-card:     #ffffff;
    --cv-radius:      10px;
    --cv-shadow:      0 1px 3px rgba(0, 0, 0, 0.05);

    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    line-height: 1.35;
}

/* Defensive — see notes in mini-cart.php template */
.cv-mini-cart > ul.woocommerce-mini-cart {
    display: none !important;
}

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

.cv-mini-cart__bundle {
    background: var(--cv-bg-card);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    overflow: hidden;
    position: relative;
    box-shadow: var(--cv-shadow);
    /* Default flex children shrink to fit a constrained parent — that
     * compressed the bundle cards instead of triggering the parent scroll.
     * Force natural height so overflow on `.cv-mini-cart` engages.
     */
    flex-shrink: 0;
}

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

.cv-mini-cart__bundle.is-complete {
    border-color: var(--cv-green-mid);
}

.cv-mini-cart__bundle.is-complete::before,
.cv-mini-cart__bundle.is-incomplete::before,
.cv-mini-cart__bundle.is-alacarte::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
}
.cv-mini-cart__bundle.is-complete::before {
    background: linear-gradient(to bottom, var(--cv-green-dark), var(--cv-green-mid));
}
.cv-mini-cart__bundle.is-incomplete::before {
    background: var(--cv-gold);
}
.cv-mini-cart__bundle.is-alacarte {
    border-color: #f0d889;
}
.cv-mini-cart__bundle.is-alacarte::before {
    background: var(--cv-gold);
}

/* ───── Bundle head — single row: title + chips inline ───── */

.cv-mini-cart__bundle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 7px 10px 7px 14px;
    background: linear-gradient(180deg, #fbfdfa 0%, #ffffff 100%);
    border-bottom: 1px solid var(--cv-border);
}
.cv-mini-cart__bundle.is-alacarte .cv-mini-cart__bundle-head {
    background: linear-gradient(180deg, #fffaeb 0%, #ffffff 100%);
}

.cv-mini-cart__bundle-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--cv-green-dark);
    line-height: 1.2;
}

.cv-mini-cart__chips {
    display: inline-flex;
    gap: 4px;
}

.cv-mini-cart__chip {
    display: inline-flex;
    align-items: center;
    padding: 0 7px;
    border-radius: 999px;
    background: #f1f4ee;
    color: var(--cv-text-muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.7;
}
.cv-mini-cart__chip.is-done {
    background: var(--cv-green-light);
    color: var(--cv-green-dark);
}

/* ───── Items list — compact rows ───── */

.cv-mini-cart__items {
    list-style: none;
    margin: 0;
    padding: 2px 10px 2px 14px;
    display: flex;
    flex-direction: column;
}

/* Specificity bump: theme + woocommerce stylesheets target generic `<li>`
 * with `display: block` and beat a single-class selector. Chain twice so
 * the grid layout sticks regardless of the parent stylesheet that wins.
 */
.cv-mini-cart .cv-mini-cart__items .cv-mini-cart__item,
.jet-blocks-cart__list .cv-mini-cart__item {
    position: relative;
    display: grid;
    grid-template-columns: 36px 1fr;
    align-items: center;
    gap: 8px;
    padding: 5px 22px 5px 0;
    margin: 0;
    border-bottom: 1px dotted #f0f0f0;
    list-style: none;
}
.cv-mini-cart .cv-mini-cart__items .cv-mini-cart__item:last-child,
.jet-blocks-cart__list .cv-mini-cart__item:last-child {
    border-bottom: none;
}

.cv-mini-cart__item-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    background: #f7f7f7;
    flex-shrink: 0;
}
.cv-mini-cart__item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
}

.cv-mini-cart__item-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.cv-mini-cart__item-name {
    font-size: 12px;
    font-weight: 600;
    color: #1f2a22;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.cv-mini-cart__item-name a {
    color: inherit;
    text-decoration: none;
}
.cv-mini-cart__item-name a:hover {
    color: var(--cv-green-dark);
}

.cv-mini-cart__item-meta {
    font-size: 10.5px;
    color: var(--cv-text-muted);
    line-height: 1.3;
}
.cv-mini-cart__item-meta dl,
.cv-mini-cart__item-meta p {
    margin: 0;
}
.cv-mini-cart__item-meta dt,
.cv-mini-cart__item-meta dd {
    display: inline;
    margin: 0;
    font-weight: 400;
}
.cv-mini-cart__item-meta dt::after {
    content: ' ';
}

.cv-mini-cart__item-qty {
    font-size: 11px;
    color: var(--cv-text-muted);
    font-weight: 500;
    line-height: 1.3;
    margin-top: 1px;
}
.cv-mini-cart__item-qty .amount,
.cv-mini-cart__item-qty bdi {
    color: var(--cv-green-dark);
    font-weight: 700;
}

/* ───── Remove × button ───── */

.cv-mini-cart__remove,
.cv-mini-cart .remove_from_cart_button {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background: transparent;
    color: var(--cv-text-muted) !important;
    font-size: 16px;
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease;
}
.cv-mini-cart__remove:hover,
.cv-mini-cart .remove_from_cart_button:hover {
    background: #fae3e3;
    color: #c0392b !important;
}

/* ───── Bundle foot (subtotal per bundle) ───── */

.cv-mini-cart__bundle-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 6px 14px;
    background: #fafbf9;
    border-top: 1px solid var(--cv-border);
    font-size: 11.5px;
}

.cv-mini-cart__bundle-foot-label {
    color: var(--cv-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.cv-mini-cart__bundle-foot-amount {
    font-size: 13px;
    font-weight: 700;
    color: var(--cv-green-dark);
}

/* ───── Sticky footer (total + buttons) — visual polish ───── */

.jet-blocks-cart__list .woocommerce-mini-cart__total.total {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--cv-border, #e3e3e3);
    font-size: 14px;
}

.jet-blocks-cart__list .woocommerce-mini-cart__total .amount {
    color: #497D59;
    font-weight: 700;
}

.jet-blocks-cart__list .woocommerce-mini-cart__buttons.buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

/* ───── Mobile shrink ───── */

@media (max-width: 480px) {
    .cv-mini-cart {
        font-size: 12.5px;
    }
    .cv-mini-cart__bundle-title {
        font-size: 12.5px;
    }
    .cv-mini-cart__item-thumb {
        width: 32px;
        height: 32px;
    }
    .cv-mini-cart__item {
        grid-template-columns: 32px 1fr;
        padding-right: 22px;
    }
}
