/* The cart pop-up (CartModal.razor, Bootstrap modal #cart-modal) in the checkout design: a 400px panel under the
   header's cart button, full width on a phone. Flat, 8px corners. The Checkout button is the site's teal fill, and the
   design's lighter #5BBFB3 only on the checkout page itself (the owner's choice for that page alone).
   Every rule is scoped to #cart-modal; it replaces legacy navbar.css's .cart-modal-right position and size only. */

#cart-modal .cart-modal-right {
    top: 68px;
    right: 48px;
    width: 400px;
    max-width: calc(100vw - 32px);
    margin: 0;
}

#cart-modal .modal-content {
    display: flex;
    flex-direction: column;
    /* dvh is the height the browser actually shows: a phone's vh includes the strip behind its toolbars, which hid
       the Checkout button below them with nothing left to scroll. vh stays for browsers without dvh. */
    max-height: min(560px, calc(100vh - 100px));
    max-height: min(560px, calc(100dvh - 100px));
    /* On a very short screen (400% zoom on a laptop) the heading and footer alone are taller than this, so it scrolls to
       keep the Checkout link in reach. */
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--slate-200);
    border-radius: var(--tb-radius-card);
    box-shadow: none;
    font-family: var(--font-sans);
}

#cart-modal .modal-header {
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-100);
}

#cart-modal .modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--slate-900);
}

#cart-modal .tb-cart-modal-count {
    margin-left: 4px;
    font-weight: 500;
    color: var(--slate-400);
}

#cart-modal .btn-close {
    margin: 0 0 0 auto;
}

#cart-modal .modal-body {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    padding: 0 20px;
}

#cart-modal .tb-cart-empty {
    margin: 0;
    padding: 24px 0;
    font-size: 13px;
    color: var(--slate-500);
}

#cart-modal .tb-cart-line {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px 0;
}

#cart-modal .tb-cart-line + .tb-cart-line {
    border-top: 1px solid var(--slate-100);
}

#cart-modal .tb-cart-thumb {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
}

#cart-modal .tb-cart-line-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--slate-600);
    overflow-wrap: anywhere;
}

#cart-modal .tb-cart-line-body span {
    font-weight: 700;
    color: var(--slate-900);
}

#cart-modal .tb-cart-line-name {
    margin-bottom: 2px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--slate-900);
}

#cart-modal .tb-cart-line-price {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}

#cart-modal .tb-cart-line-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#cart-modal .tb-cart-line-actions form {
    margin: 0;
}

#cart-modal .tb-cart-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--tb-radius-control);
    background: transparent;
    color: var(--slate-500);
    cursor: pointer;
}

#cart-modal .tb-cart-icon:hover,
#cart-modal .tb-cart-icon:focus-visible {
    background: var(--slate-100);
    color: var(--slate-900);
}

#cart-modal .tb-cart-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--slate-100);
}

#cart-modal .tb-cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

#cart-modal .tb-cart-subtotal span {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-700);
}

#cart-modal .tb-cart-subtotal strong {
    font-size: 17px;
    font-weight: 700;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}

#cart-modal .tb-cart-rounding-note {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--slate-600);
}

#cart-modal .tb-cart-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    border-radius: var(--tb-radius-control);
    background: var(--tb-teal-fill);
    color: var(--tb-teal-fill-text);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

#cart-modal .tb-cart-checkout:hover,
#cart-modal .tb-cart-checkout:focus-visible {
    color: var(--tb-teal-fill-text);
    transform: var(--tb-lift);
}

body:has(.tb-checkout) #cart-modal .tb-cart-checkout {
    background: var(--tb-teal-ui);
    color: #fff;
}

body:has(.tb-checkout) #cart-modal .tb-cart-checkout:hover,
body:has(.tb-checkout) #cart-modal .tb-cart-checkout:focus-visible {
    background: var(--tb-teal-ui-dark);
    color: #fff;
}

@media (max-width: 575.98px) {
    #cart-modal .cart-modal-right {
        top: 56px;
        right: 0;
        left: 0;
        width: auto;
        max-width: none;
    }

    #cart-modal .modal-content {
        max-height: calc(100vh - 56px);
        max-height: calc(100dvh - 56px);
        border-radius: 0 0 var(--tb-radius-card) var(--tb-radius-card);
    }
}
