/**
 * CartSetup Cart Drawer Styles
 *
 * Covers the drawer panel (slide-in from right), the overlay backdrop,
 * and the responsive bottom-sheet layout for mobile.
 *
 * Z-INDEX RULE: Use CSS variables set from UPSELLMAX.Z in floating-ui.css.
 * No literal z-index values allowed. @see Section 16.3
 *
 * @package UpsellMax\CartSetup
 * @see     Section 12 — CSS asset owned by drawer layer
 * @see     Section 18.1 — Responsive layout rules
 */

/* ── Overlay Backdrop ─────────────────────────────────────────────────── */
.um-drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--umscs-color-overlay);
    z-index: calc(var(--umscs-z-drawer) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--umscs-transition);
}

.um-drawer-overlay--visible {
    opacity: 1;
    pointer-events: all;
}

/* ── Drawer Panel ─────────────────────────────────────────────────────── */
.um-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--umscs-drawer-width);
    max-width: 100vw;
    background: var(--umscs-color-surface);
    z-index: var(--umscs-z-drawer);
    display: flex;
    flex-direction: column;
    box-shadow: var(--umscs-shadow);
    transform: translateX(100%);
    transition: transform var(--umscs-transition);
    border-radius: var(--umscs-radius) 0 0 var(--umscs-radius);
    font-family: var(--umscs-font);
}

.um-drawer--open {
    transform: translateX(0);
}

/* ── Drawer: Header ───────────────────────────────────────────────────── */
.um-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.um-drawer__title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #111;
}

.um-drawer__close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.06);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background var(--umscs-transition);
    flex-shrink: 0;
}

.um-drawer__close:hover {
    background: rgba(0,0,0,0.12);
}

.um-drawer__close:focus-visible {
    outline: 2px solid var(--umscs-color-primary);
    outline-offset: 2px;
}

/* ── Drawer: Body (scrollable) ────────────────────────────────────────── */
.um-drawer__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0;
}

/* WooCommerce mini-cart overrides inside drawer */
.um-drawer__body .woocommerce-mini-cart {
    padding: 0 24px;
    list-style: none;
    margin: 0;
}

.um-drawer__body .woocommerce-mini-cart-item {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.um-drawer__body .woocommerce-mini-cart-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ── Drawer: Footer ───────────────────────────────────────────────────── */
.um-drawer__footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.um-drawer__footer-total {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
    color: #111;
    margin-bottom: 4px;
}

/* CTA buttons in footer */
.um-drawer__footer .button,
.um-drawer__footer .checkout-button {
    display: block;
    width: 100%;
    padding: 14px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    border-radius: 8px;
    transition: background var(--umscs-transition), transform 0.1s;
    text-decoration: none;
    cursor: pointer;
    border: none;
}

.um-drawer__footer .checkout-button {
    background: var(--umscs-color-primary);
    color: #fff;
}

.um-drawer__footer .checkout-button:hover {
    background: #1557b0;
    color: #fff;
}

/* ── Admin bar offset ─────────────────────────────────────────────────── */
/* JS measures the actual admin bar height and sets --umscs-adminbar-h.       */
.admin-bar .um-drawer {
    top: var(--umscs-adminbar-h, 32px);
}

/* ── Mobile: Bottom Sheet ─────────────────────────────────────────────── */
/* @see Section 18.1 — "Viewport width < 768px → Bottom sheet"             */
@media (max-width: 767px) {
    .um-drawer {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 90vh;
        border-radius: var(--umscs-radius) var(--umscs-radius) 0 0;
        transform: translateY(100%);
    }

    .um-drawer--open {
        transform: translateY(0);
    }

    /* Bottom sheet drag handle */
    .um-drawer__header::before {
        content: '';
        display: block;
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(0,0,0,0.18);
        border-radius: 2px;
    }
}

/* ── Tablet ───────────────────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
    .um-drawer {
        width: var(--umscs-drawer-width-tablet);
    }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .um-drawer,
    .um-drawer-overlay {
        transition: none;
    }
}

/* ── High contrast ────────────────────────────────────────────────────── */
@media (forced-colors: active) {
    .um-drawer {
        border: 2px solid ButtonText;
    }
}
