
/* =========================================================================
   LuperIQ Universal Cart — Drawer Stylesheet
   =========================================================================
   Adapts automatically to any Theme Studio theme via CSS custom properties.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. CSS Variables — Theme-aware palette
   ------------------------------------------------------------------------- */

.liq-cart-drawer, .liq-cart-icon, .liq-cart-toast {
    /* Brand token bridge: ThemeStudio --brand-* → --luperiq-* → hex fallback.
       Customer sites set --brand-* on :root; luperiq.com uses --luperiq-*.
       If neither is set the hex fallbacks keep the cart looking correct. */
    --cart-primary: var(--brand-primary, var(--luperiq-accent, #3b82f6));
    --cart-accent:  var(--brand-accent,  var(--luperiq-accent, #3b82f6));
    --cart-bg:      var(--brand-bg,      var(--luperiq-surface, #ffffff));
    --cart-text:    var(--brand-text,    var(--luperiq-text, #1e293b));
    --cart-muted:   var(--brand-text-muted, color-mix(in srgb, var(--luperiq-text, #1e293b) 60%, transparent));
    --cart-border:  var(--brand-border,  color-mix(in srgb, var(--luperiq-text, #1e293b) 15%, transparent));
    --cart-hover:   color-mix(in srgb, var(--luperiq-text, #1e293b) 6%, transparent);
    --cart-success: #16a34a;
    --cart-danger:  #dc2626;
    --cart-shadow:  0 8px 30px rgba(0, 0, 0, 0.18);
    --cart-radius:  8px;
}

/* -------------------------------------------------------------------------
   2. Backdrop
   ------------------------------------------------------------------------- */

.liq-cart-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9997;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 300ms ease;
}

.liq-cart-backdrop.open {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

/* -------------------------------------------------------------------------
   3. Drawer container — slides from right
   ------------------------------------------------------------------------- */

.liq-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;

    display: flex;
    flex-direction: column;

    background: var(--cart-bg);
    color: var(--cart-text);
    box-shadow: var(--cart-shadow);

    transform: translateX(100%);
    transition: transform 300ms ease;

    font-family: var(--luperiq-font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* -------------------------------------------------------------------------
   4. Drawer header
   ------------------------------------------------------------------------- */

.liq-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cart-border);
    flex-shrink: 0;
}

.liq-cart-header h2,
.liq-cart-header .liq-cart-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--cart-text);
    letter-spacing: -0.01em;
}

.liq-cart-header button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cart-muted);
    font-size: 22px;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    line-height: 1;
    flex-shrink: 0;
}

.liq-cart-header button:hover {
    background: var(--cart-hover);
    color: var(--cart-text);
}

/* -------------------------------------------------------------------------
   5. Scrollable item list
   ------------------------------------------------------------------------- */

.liq-cart-items {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Thin custom scrollbar */
.liq-cart-items::-webkit-scrollbar {
    width: 5px;
}

.liq-cart-items::-webkit-scrollbar-track {
    background: transparent;
}

.liq-cart-items::-webkit-scrollbar-thumb {
    background: var(--cart-border);
    border-radius: 3px;
}

/* -------------------------------------------------------------------------
   6. Individual item card
   ------------------------------------------------------------------------- */

.liq-cart-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--cart-border);
    position: relative;
}

.liq-cart-item:last-child {
    border-bottom: none;
}

/* Product thumbnail */
.liq-cart-item-img {
    width: 64px;
    height: 64px;
    border-radius: var(--cart-radius);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--cart-hover);
}

/* Name + variant + price column */
.liq-cart-item-info {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.liq-cart-item-info .liq-cart-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--cart-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.liq-cart-item-info .liq-cart-item-variant {
    font-size: 12px;
    color: var(--cart-muted);
}

.liq-cart-item-info .liq-cart-item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--cart-text);
    margin-top: auto;
}

/* -------------------------------------------------------------------------
   7. Quantity stepper
   ------------------------------------------------------------------------- */

.liq-cart-item-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--cart-border);
    border-radius: var(--cart-radius);
    overflow: hidden;
    flex-shrink: 0;
    align-self: flex-end;
}

.liq-cart-item-qty button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--cart-text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.liq-cart-item-qty button:hover {
    background: var(--cart-hover);
}

.liq-cart-item-qty button:active {
    background: var(--cart-border);
}

.liq-cart-item-qty span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cart-text);
    border-left: 1px solid var(--cart-border);
    border-right: 1px solid var(--cart-border);
    user-select: none;
}

/* -------------------------------------------------------------------------
   8. Remove item button
   ------------------------------------------------------------------------- */

.liq-cart-item-remove {
    position: absolute;
    top: 10px;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cart-muted);
    font-size: 14px;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    opacity: 0.6;
}

.liq-cart-item-remove:hover {
    background: color-mix(in srgb, var(--cart-danger) 12%, transparent);
    color: var(--cart-danger);
    opacity: 1;
}

/* -------------------------------------------------------------------------
   9. Footer — subtotal + checkout
   ------------------------------------------------------------------------- */

.liq-cart-footer {
    flex-shrink: 0;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--cart-border);
    background: var(--cart-bg);
}

.liq-cart-subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 16px;
}

.liq-cart-subtotal .liq-cart-subtotal-label {
    font-weight: 500;
    color: var(--cart-muted);
}

.liq-cart-subtotal .liq-cart-subtotal-value {
    font-weight: 700;
    font-size: 18px;
    color: var(--cart-text);
}

.liq-cart-checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    padding: 0 24px;
    border: none;
    border-radius: var(--cart-radius);
    background: var(--cart-accent);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 150ms ease, transform 100ms ease, box-shadow 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.liq-cart-checkout-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--cart-accent) 40%, transparent);
}

.liq-cart-checkout-btn:active {
    transform: scale(0.98);
}

.liq-cart-checkout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
    transform: none;
}

/* -------------------------------------------------------------------------
   10. Empty state
   ------------------------------------------------------------------------- */

.liq-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    flex: 1 1 auto;
}

.liq-cart-empty svg,
.liq-cart-empty .liq-cart-empty-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    color: var(--cart-border);
    opacity: 0.7;
}

.liq-cart-empty p {
    margin: 0;
    font-size: 15px;
    color: var(--cart-muted);
    line-height: 1.5;
}

.liq-cart-empty a {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 24px;
    border-radius: var(--cart-radius);
    background: var(--cart-accent);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: filter 150ms ease;
}

.liq-cart-empty a:hover {
    filter: brightness(1.08);
}

/* -------------------------------------------------------------------------
   11. Loading skeleton
   ------------------------------------------------------------------------- */

.liq-cart-loading {
    padding: 16px 0;
}

.liq-cart-loading .liq-cart-skeleton {
    display: flex;
    gap: 12px;
    padding: 14px 0;
}

.liq-cart-skeleton-img,
.liq-cart-skeleton-line {
    border-radius: var(--cart-radius);
    background: linear-gradient(
        90deg,
        var(--cart-hover) 25%,
        var(--cart-border) 50%,
        var(--cart-hover) 75%
    );
    background-size: 200% 100%;
    animation: liq-cart-shimmer 1.5s ease infinite;
}

.liq-cart-skeleton-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.liq-cart-skeleton-line {
    height: 14px;
    border-radius: 4px;
}

.liq-cart-skeleton-line:nth-child(1) { width: 70%; }
.liq-cart-skeleton-line:nth-child(2) { width: 45%; margin-top: 6px; }
.liq-cart-skeleton-line:nth-child(3) { width: 30%; margin-top: auto; }

@keyframes liq-cart-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* -------------------------------------------------------------------------
   12. Floating cart icon + badge
   ------------------------------------------------------------------------- */

.liq-cart-icon {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--cart-accent);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transition: transform 200ms ease, box-shadow 200ms ease;
    -webkit-tap-highlight-color: transparent;
}

.liq-cart-icon:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.liq-cart-icon:active {
    transform: scale(0.95);
}

.liq-cart-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dedicated full cart pages do not need a second floating cart trigger. */
body:has(.rm-cart-section) .liq-cart-icon {
    display: none !important;
}

/* Item count badge */
.liq-cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--cart-danger, #dc2626);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transform: scale(1);
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Bounce animation when count changes */
.liq-cart-badge.liq-cart-badge-bump {
    transform: scale(1.3);
}

/* Hide badge when count is zero */
.liq-cart-badge:empty,
.liq-cart-badge[data-count="0"] {
    display: none;
}

/* -------------------------------------------------------------------------
   13. Toast notification
   ------------------------------------------------------------------------- */

.liq-cart-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 10000;

    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--cart-radius);
    background: var(--cart-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);

    transform: translate(-50%, 80px);
    opacity: 0;
    pointer-events: none;
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 300ms ease;
}

.liq-cart-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.liq-cart-toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   14. Email capture form
   ------------------------------------------------------------------------- */

.liq-cart-email-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 0 0;
}

.liq-cart-email-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cart-muted);
}

.liq-cart-email-form .liq-cart-email-row {
    display: flex;
    gap: 8px;
}

.liq-cart-email-form input[type="email"] {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--cart-border);
    border-radius: var(--cart-radius);
    background: var(--cart-bg);
    color: var(--cart-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.liq-cart-email-form input[type="email"]:focus {
    border-color: var(--cart-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cart-accent) 20%, transparent);
}

.liq-cart-email-form input[type="email"]::placeholder {
    color: var(--cart-muted);
    opacity: 0.6;
}

.liq-cart-email-form button {
    flex-shrink: 0;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: var(--cart-radius);
    background: var(--cart-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: filter 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.liq-cart-email-form button:hover {
    filter: brightness(1.08);
}

.liq-cart-email-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.liq-cart-email-form .liq-cart-email-error {
    font-size: 12px;
    color: var(--cart-danger);
    margin-top: -4px;
}

/* -------------------------------------------------------------------------
   15. Utility — visually hidden but accessible
   ------------------------------------------------------------------------- */

.liq-cart-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* -------------------------------------------------------------------------
   16. Mobile responsive — full-width drawer below 640px
   ------------------------------------------------------------------------- */

@media (max-width: 639px) {
    .liq-cart-drawer {
        width: 100%;
    }

    .liq-cart-icon {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .liq-cart-icon svg {
        width: 24px;
        height: 24px;
    }

    .liq-cart-header {
        padding: 14px 16px;
    }

    .liq-cart-items {
        padding: 10px 16px;
    }

    .liq-cart-footer {
        padding: 14px 16px 16px;
        /* Safe area for phones with gesture bars */
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .liq-cart-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        transform: translate(0, 80px);
        text-align: center;
        justify-content: center;
        white-space: normal;
    }

    .liq-cart-toast.show {
        transform: translate(0, 0);
    }

    /* Ensure tappable targets are at least 44px */
    .liq-cart-item-qty button {
        width: 36px;
        height: 36px;
    }

    .liq-cart-item-qty span {
        min-width: 36px;
        height: 36px;
    }

    .liq-cart-header button {
        width: 44px;
        height: 44px;
    }

    .liq-cart-item-remove {
        width: 32px;
        height: 32px;
    }
}

/* -------------------------------------------------------------------------
   17. Prefers-reduced-motion
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .liq-cart-drawer,
    .liq-cart-backdrop,
    .liq-cart-toast,
    .liq-cart-icon,
    .liq-cart-badge,
    .liq-cart-checkout-btn {
        transition-duration: 0ms !important;
    }

    @keyframes liq-cart-shimmer {
        from, to { background-position: 0 0; }
    }
}

/* -------------------------------------------------------------------------
   18. Print — hide cart UI entirely
   ------------------------------------------------------------------------- */

@media print {
    .liq-cart-icon,
    .liq-cart-drawer,
    .liq-cart-backdrop,
    .liq-cart-toast {
        display: none !important;
    }
}

/* -------------------------------------------------------------------------
   19. Multi-step checkout — email form inputs (text, select)
   ------------------------------------------------------------------------- */

.liq-cart-email-form input[type="text"],
.liq-cart-email-form input[type="tel"],
.liq-cart-email-form select {
    width: 100%;
    box-sizing: border-box;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--cart-border);
    border-radius: var(--cart-radius);
    background: var(--cart-bg);
    color: var(--cart-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.liq-cart-email-form input[type="text"]:focus,
.liq-cart-email-form input[type="tel"]:focus,
.liq-cart-email-form select:focus {
    border-color: var(--cart-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cart-accent) 20%, transparent);
}

.liq-cart-email-form input[type="text"]::placeholder,
.liq-cart-email-form input[type="tel"]::placeholder {
    color: var(--cart-muted);
    opacity: 0.6;
}

/* -------------------------------------------------------------------------
   20. Multi-step checkout — shipping row (state + zip side by side)
   ------------------------------------------------------------------------- */

.liq-cart-shipping-row {
    display: flex;
    gap: 8px;
}

.liq-cart-shipping-row select {
    flex: 1 1 50%;
    min-width: 0;
}

.liq-cart-shipping-row input {
    flex: 1 1 40%;
    min-width: 0;
}

/* -------------------------------------------------------------------------
   21. Multi-step checkout — promo code row
   ------------------------------------------------------------------------- */

.liq-cart-promo-row {
    display: flex;
    gap: 8px;
}

.liq-cart-promo-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--cart-border);
    border-radius: var(--cart-radius);
    background: var(--cart-bg);
    color: var(--cart-text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 150ms ease;
}

.liq-cart-promo-input:focus {
    border-color: var(--cart-accent);
}

.liq-cart-promo-apply {
    flex-shrink: 0;
    height: 36px;
    padding: 0 14px;
    border: none;
    border-radius: var(--cart-radius);
    background: var(--cart-hover);
    color: var(--cart-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 150ms ease;
}

.liq-cart-promo-apply:hover {
    background: var(--cart-border);
}

.liq-cart-promo-apply:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.liq-cart-promo-msg {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
}

/* -------------------------------------------------------------------------
   22. Multi-step checkout — order summary lines
   ------------------------------------------------------------------------- */

.liq-cart-summary-lines {
    border-top: 1px solid var(--cart-border);
    padding-top: 10px;
}

.liq-cart-summary-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--cart-text);
}

.liq-cart-summary-line-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--cart-muted);
}

.liq-cart-summary-line-price {
    flex-shrink: 0;
    font-weight: 600;
}

.liq-cart-summary-subtotal {
    border-top: 1px solid var(--cart-border);
    margin-top: 6px;
    padding-top: 8px;
    font-size: 13px;
    color: var(--cart-muted);
}

.liq-cart-summary-discount .liq-cart-summary-discount-val {
    color: var(--cart-success, #16a34a);
}

.liq-cart-summary-total {
    border-top: 2px solid var(--cart-border);
    margin-top: 4px;
    padding-top: 8px;
    font-size: 15px;
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   23. Multi-step checkout — back button
   ------------------------------------------------------------------------- */

.liq-cart-back-btn {
    background: transparent;
    border: none;
    color: var(--cart-muted);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 0;
    text-align: left;
    transition: color 150ms ease;
}

.liq-cart-back-btn:hover {
    color: var(--cart-text);
}

/* -------------------------------------------------------------------------
   24. Multi-step checkout — dynamic panel wrapper
   ------------------------------------------------------------------------- */

.liq-cart-dynamic-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.liq-cart-email-form .liq-cart-email-submit {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: var(--cart-radius);
    background: var(--cart-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter 150ms ease;
    -webkit-tap-highlight-color: transparent;
}

.liq-cart-email-form .liq-cart-email-submit:hover {
    filter: brightness(1.08);
}

.liq-cart-email-form .liq-cart-email-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
}
