/*
 * Side cart drawer: layout, items, empty state and footer.
 * Scoped to #cart-drawer and loaded after style.css, so the older cart-drawer rules there are overridden.
 * Phones get a full-width sheet; larger screens get a 440px panel.
 */

#cart-drawer.cart-drawer {
    right: 0;
    width: min(440px, 100vw);
    max-width: 100vw;
    background: #ffffff;
    box-shadow: -24px 0 60px -24px rgba(11, 15, 23, 0.45);
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.32s ease;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: #0b0f17;
}

#cart-drawer.cart-drawer.active {
    transform: none;
}

#cart-drawer [hidden] {
    display: none !important;
}

#cart-drawer .drawer-contents {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Header */
#cart-drawer .drawer-fixed-header {
    flex: 0 0 auto;
    padding: 18px 20px;
    border-bottom: 1px solid #eef1f6;
    background: #ffffff;
}

#cart-drawer .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#cart-drawer .drawer-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: #0b0f17;
}

#cart-drawer .itg-cart__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    background: #e11d2a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

#cart-drawer .drawer-close button.drawer-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f4f9;
    color: #0b0f17;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#cart-drawer .drawer-close button.drawer-close-btn:hover {
    background: #fdecec;
    color: #e11d2a;
}

/* Body: the only part that scrolls */
#cart-drawer .drawer-inner {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: 0 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#cart-drawer .itg-cart {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

#cart-drawer .itg-cart__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

/* Items */
#cart-drawer .itg-cart__list {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

#cart-drawer .itg-cart__item {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 14px;
    padding: 18px 0;
    border-bottom: 1px solid #eef1f6;
    transition: opacity 0.2s ease;
}

#cart-drawer .itg-cart__item:last-child {
    border-bottom: 0;
}

#cart-drawer .itg-cart__item.is-removing {
    opacity: 0.45;
    pointer-events: none;
}

#cart-drawer .itg-cart__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    padding: 8px;
    border: 1px solid #e3e8f0;
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f8 100%);
}

#cart-drawer .itg-cart__thumb img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#cart-drawer .itg-cart__info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

#cart-drawer .itg-cart__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

#cart-drawer .itg-cart__name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: #0b0f17;
    text-decoration: none;
}

#cart-drawer .itg-cart__name:hover {
    color: #e11d2a;
}

#cart-drawer .itg-cart__remove {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: -6px -6px 0 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #8a94a6;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#cart-drawer .itg-cart__remove:hover,
#cart-drawer .itg-cart__remove:focus-visible {
    background: #fdecec;
    color: #e11d2a;
}

#cart-drawer .itg-cart__variant {
    width: max-content;
    max-width: 100%;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f1f4f9;
    color: #5b6577;
    font-size: 12px;
    font-weight: 500;
}

#cart-drawer .itg-cart__unit {
    margin: 0;
    font-size: 13px;
    color: #5b6577;
}

#cart-drawer .itg-cart__unit .price {
    font-weight: 600;
    color: #0b0f17;
}

#cart-drawer .itg-cart__times {
    margin-left: 4px;
    color: #9aa6b8;
}

#cart-drawer .itg-cart__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    margin-top: auto;
    padding-top: 6px;
}

/* Quantity stepper */
#cart-drawer .itg-cart__stepper {
    display: inline-flex;
    align-items: center;
    height: 38px;
    border: 1px solid #d9e0ea;
    border-radius: 999px;
    background: #ffffff;
    overflow: hidden;
}

#cart-drawer .itg-cart__stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #0b0f17;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#cart-drawer .itg-cart__stepper button:hover:not(:disabled) {
    background: #f1f4f9;
    color: #e11d2a;
}

#cart-drawer .itg-cart__stepper button:disabled {
    color: #c3cad6;
    cursor: not-allowed;
}

#cart-drawer .itg-cart__stepper input.js-qty-num {
    width: 36px;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #0b0f17;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    box-shadow: none;
}

#cart-drawer .itg-cart__line {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

#cart-drawer .itg-cart__qty-note {
    font-size: 12px;
    color: #9aa6b8;
}

#cart-drawer .itg-cart__line .cart-price {
    font-size: 16px;
    font-weight: 700;
    color: #0b0f17;
    white-space: nowrap;
}

/* Empty state */
#cart-drawer .itg-cart__empty {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 320px;
    margin: 0 auto;
    padding: 48px 8px;
    text-align: center;
}

#cart-drawer .itg-cart__empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin-bottom: 8px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff1f1 0%, #fde3e4 100%);
    color: #e11d2a;
}

#cart-drawer .itg-cart__empty-title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    color: #0b0f17;
}

#cart-drawer .itg-cart__empty-text {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.55;
    color: #5b6577;
}

/* Footer: subtotal and actions, pinned to the bottom */
#cart-drawer .itg-cart__footer {
    flex: 0 0 auto;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #eef1f6;
    background: #ffffff;
    box-shadow: 0 -16px 30px -24px rgba(11, 15, 23, 0.35);
}

#cart-drawer .itg-cart__summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

#cart-drawer .itg-cart__summary-label {
    font-size: 14px;
    font-weight: 500;
    color: #5b6577;
}

#cart-drawer .itg-cart__summary-count {
    margin-left: 4px;
    font-size: 12px;
    color: #9aa6b8;
}

#cart-drawer .itg-cart__summary-total {
    font-size: 22px;
    font-weight: 700;
    color: #0b0f17;
    white-space: nowrap;
}

#cart-drawer .itg-cart__note {
    margin: 4px 0 14px;
    font-size: 12px;
    color: #9aa6b8;
}

#cart-drawer .itg-cart__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 10px;
}

#cart-drawer .itg-cart__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

#cart-drawer .itg-cart__btn:active {
    transform: scale(0.98);
}

#cart-drawer .itg-cart__btn--ghost {
    border-color: #d9e0ea;
    background: #ffffff;
    color: #0b0f17;
}

#cart-drawer .itg-cart__btn--ghost:hover {
    background: #f5f7fb;
    color: #0b0f17;
}

#cart-drawer .itg-cart__btn--primary {
    background: #e11d2a;
    color: #ffffff;
    box-shadow: 0 14px 24px -14px rgba(225, 29, 42, 0.75);
}

#cart-drawer .itg-cart__btn--primary:hover {
    background: #c4121e;
    color: #ffffff;
}

#cart-drawer .itg-cart__btn--wide {
    width: 100%;
}

#cart-drawer .itg-cart__btn:focus-visible,
#cart-drawer .itg-cart__stepper button:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

/* Phones: a little tighter, and the thumbnails shrink */
@media (max-width: 575.98px) {
    #cart-drawer .drawer-fixed-header {
        padding: 16px;
    }

    #cart-drawer .drawer-inner {
        padding: 0 16px;
    }

    #cart-drawer .itg-cart__footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    #cart-drawer .itg-cart__item {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 12px;
    }

    #cart-drawer .itg-cart__thumb {
        width: 76px;
        height: 76px;
        border-radius: 14px;
    }

    #cart-drawer .itg-cart__name {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #cart-drawer.cart-drawer,
    #cart-drawer .itg-cart__item,
    #cart-drawer .itg-cart__btn {
        transition: none !important;
    }
}

/* style.css carries an older cart list block (ul.cart-items, li.cart-item). Reset what it adds here. */
#cart-drawer ul.itg-cart__list.cart-items {
    padding: 4px 0;
}

#cart-drawer ul.itg-cart__list.cart-items > li.cart-item {
    border-top: 0;
}

#cart-drawer .itg-cart__stepper.js-qty-wrapper {
    width: auto;
}
