/* ============================================================
   Max Saver Pack — floating widget
   ------------------------------------------------------------
   Premium, gamified, quick-commerce feel.
   - Sticky launcher bottom-right on desktop.
   - Bottom-sheet on mobile (slide-up + drag handle).
   - Animated progress bar with tier dots.
   - Tier-unlock + confetti celebration animations.
   ============================================================ */

.saver-pack-widget {
    position: fixed;
    z-index: 9000;
    right: 16px;
    bottom: 90px;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    color: #1a1a1a;
}

.saver-pack-widget[data-state="hidden"] { display: none; }

/* ---------- Launcher pill ---------- */

.saver-pack-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 12px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(212, 181, 92, 0.35), 0 2px 8px rgba(0,0,0,0.18);
    transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
    position: relative;
    max-width: 320px;
}
.saver-pack-launcher:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 36px rgba(212, 181, 92, 0.45);
}
.saver-pack-launcher__pulse {
    position: absolute;
    inset: -3px;
    border-radius: 999px;
    border: 2px solid #D4B55C;
    opacity: .7;
    animation: saver-pulse 2s infinite;
    pointer-events: none;
}
@keyframes saver-pulse {
    0%   { transform: scale(1);    opacity: .7; }
    70%  { transform: scale(1.06); opacity: 0;  }
    100% { transform: scale(1.06); opacity: 0;  }
}
.saver-pack-launcher__icon {
    flex: 0 0 auto;
    color: #D4B55C;
    filter: drop-shadow(0 0 6px rgba(212,181,92,0.45));
    animation: saver-spin 4s linear infinite;
}
@keyframes saver-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.saver-pack-launcher__text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: left;
    overflow: hidden;
    max-width: 230px;
}
.saver-pack-launcher__title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.saver-pack-launcher__sub {
    font-size: 11px;
    font-weight: 500;
    color: #D4B55C;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.saver-pack-launcher__chevron {
    color: #D4B55C;
    font-size: 22px;
    line-height: 1;
    transform: translateY(-1px);
}

/* ---------- Sheet (open state) ---------- */

.saver-pack-sheet {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: 360px;
    max-width: calc(100vw - 24px);
    background: #ffffff !important;
    color: #1a1a1a;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
    padding: 18px 18px 14px;
    transform: translateY(8px) scale(.98);
    opacity: 0;
    pointer-events: none;
    transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .2s;
    overflow: hidden;
    font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
    isolation: isolate;
}
.saver-pack-sheet *,
.saver-pack-sheet *::before,
.saver-pack-sheet *::after {
    box-sizing: border-box;
}
.saver-pack-widget[data-state="open"] .saver-pack-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.saver-pack-sheet__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
    background: #ffffff !important;
    color: #1a1a1a !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .15s, border-color .15s;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.saver-pack-sheet__close:hover {
    background: #f5f5f5 !important;
    border-color: rgba(0,0,0,0.18);
    transform: scale(1.05);
}
.saver-pack-sheet__close svg {
    display: block;
    color: #1a1a1a;
    pointer-events: none;
}

.saver-pack-sheet__handle {
    display: none;
    width: 40px;
    height: 4px;
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
    margin: 4px auto 12px;
}

/* Header — row 1: badge + (title/subtitle stacked) + (space for close button) */
.saver-pack-sheet__header {
    display: grid;
    grid-template-columns: 40px 1fr;
    column-gap: 12px;
    align-items: center;
    padding-right: 36px;
    margin-bottom: 10px;
    background: #ffffff;
    position: relative;
    z-index: 2;
}
.saver-pack-sheet__badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(212,181,92,0.22) 0%, rgba(212,181,92,0.08) 100%);
    color: #D4B55C;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.saver-pack-sheet__heading-block {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.saver-pack-sheet__title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a !important;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent;
}
.saver-pack-sheet__sub {
    font-size: 12px;
    color: #777 !important;
    margin: 2px 0 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

/* Row 2: savings banner — separate from header, full-width, can't overlap */
.saver-pack-sheet__savings {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(212,181,92,0.12);
    border-radius: 10px;
    transition: background .25s;
    margin-bottom: 14px;
    position: relative;
    z-index: 2;
}
.saver-pack-sheet__savings.is-active {
    background: linear-gradient(135deg, rgba(46,125,50,0.10) 0%, rgba(46,125,50,0.18) 100%);
}
.saver-pack-sheet__savings-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    line-height: 1;
}
.saver-pack-sheet__savings.is-active .saver-pack-sheet__savings-label {
    color: #2e7d32;
}
.saver-pack-sheet__savings-amount {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a !important;
    line-height: 1;
    background: transparent;
    letter-spacing: -0.01em;
}
.saver-pack-sheet__savings.is-active .saver-pack-sheet__savings-amount {
    color: #2e7d32 !important;
}

/* ---------- Progress bar ---------- */

.saver-pack-sheet__progress-wrap { margin-bottom: 14px; }
.saver-pack-sheet__progress-track {
    position: relative;
    height: 10px;
    background: rgba(0,0,0,0.06);
    border-radius: 999px;
    overflow: visible;
}
.saver-pack-sheet__progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(90deg, #D4B55C 0%, #f0d27a 50%, #D4B55C 100%);
    background-size: 200% 100%;
    border-radius: 999px;
    transition: width .8s cubic-bezier(.2,.8,.2,1);
    animation: saver-shimmer 2s linear infinite;
    box-shadow: 0 0 12px rgba(212,181,92,0.6);
}
@keyframes saver-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.saver-pack-sheet__progress-dots {
    position: absolute;
    inset: -6px 0 -6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
    pointer-events: none;
}
.saver-pack-dot {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0,0,0,0.12);
    color: #888;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
    transition: transform .3s, background .3s, border-color .3s, color .3s;
    pointer-events: auto;
}
.saver-pack-dot.is-unlocked {
    background: #2e7d32;
    border-color: #2e7d32;
    color: #fff;
    animation: saver-pop .45s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.18);
}
@keyframes saver-pop {
    0%   { transform: scale(.6); }
    60%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.saver-pack-sheet__hint {
    margin: 12px 0 0;
    font-size: 13px;
    color: #333 !important;
    font-weight: 500;
    text-align: center;
    background: transparent;
}

/* ---------- Tier rows ---------- */

.saver-pack-sheet__tiers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0 14px;
    padding: 10px 12px;
    background: #fafafa;
    border-radius: 12px;
}
.saver-pack-tier {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
    color: #555;
    transition: color .25s;
}
.saver-pack-tier__check {
    color: #ccc;
    font-weight: 700;
    text-align: center;
}
.saver-pack-tier__label { font-weight: 500; }
.saver-pack-tier__reward {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    background: rgba(0,0,0,0.05);
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.saver-pack-tier.is-unlocked {
    color: #1a1a1a;
}
.saver-pack-tier.is-unlocked .saver-pack-tier__check {
    color: #2e7d32;
}
.saver-pack-tier.is-unlocked .saver-pack-tier__reward {
    color: #fff;
    background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%);
}

/* ---------- Recommendations ---------- */

.saver-pack-sheet__recommendations {
    border-top: 1px dashed rgba(0,0,0,0.1);
    padding-top: 12px;
}
.saver-pack-sheet__rec-title {
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.saver-pack-sheet__rec-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 120px;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.saver-pack-sheet__rec-row::-webkit-scrollbar { display: none; }
.saver-pack-rec {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    grid-template-rows: 90px auto auto auto;
    gap: 4px;
    scroll-snap-align: start;
    transition: transform .2s, box-shadow .2s;
}
.saver-pack-rec:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.saver-pack-rec__media {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f3f3;
}
.saver-pack-rec__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.saver-pack-rec__name {
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.saver-pack-rec__price {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
}
.saver-pack-rec__price del {
    font-weight: 400;
    color: #999;
    font-size: 11px;
    margin-left: 4px;
}
.saver-pack-rec__add {
    border: none;
    background: #1a1a1a;
    color: #D4B55C;
    border-radius: 8px;
    padding: 6px 0;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    transition: background .2s;
}
.saver-pack-rec__add:hover { background: #000; }
.saver-pack-rec__add:disabled { opacity: .6; cursor: wait; }

/* ---------- Empty state ---------- */

.saver-pack-sheet__empty {
    text-align: center;
    padding: 18px 0 4px;
    color: #666;
    font-size: 13px;
}
.saver-pack-sheet__cta {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: #D4B55C;
    color: #1a1a1a;
    font-weight: 700;
    border-radius: 999px;
    text-decoration: none;
    font-size: 12px;
}

/* ---------- Confetti ---------- */

.saver-pack-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 18px;
}
.saver-pack-confetti.is-firing { display: block; }
.saver-pack-confetti__dot {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    animation: saver-fall 1.2s cubic-bezier(.4,.1,.6,1) forwards;
}
@keyframes saver-fall {
    0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
    100% { transform: translateY(420px) rotate(540deg); opacity: 0; }
}

/* ---------- Lift above sticky page CTAs ----------
   Cart (<769px) and product-detail (<992px) render a fixed
   .bottom_button (PAY / Add to cart) anchored at bottom:48px
   that's ~70px tall. The launcher sits on top of it and blocks
   the tap target, so we push it above the button on those pages. */
@media (max-width: 991px) {
    body.cart-body .saver-pack-widget,
    body.product-detail-body .saver-pack-widget {
        bottom: 130px;
    }
}

/* ---------- Hide launcher while sheet is open --------
   On desktop the sheet floats above the launcher so both
   can coexist. On mobile the full-screen sheet makes the
   launcher redundant and visually overlapping — hide it. */
.saver-pack-widget[data-state="open"] .saver-pack-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
    transition: opacity .18s, transform .18s;
}

/* ---------- Mobile: compact icon-only FAB ----------
   The full pill (≈220 px wide) sits on top of page content
   and blocks taps on underlying buttons. Collapse it to a
   44 px circular FAB — same tap target, 80% smaller footprint. */
@media (max-width: 640px) {
    .saver-pack-widget {
        right: 12px;
        bottom: 76px;
    }
    body.cart-body .saver-pack-widget,
    body.product-detail-body .saver-pack-widget {
        bottom: 130px;
    }

    /* Collapse pill → circle FAB */
    .saver-pack-launcher {
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        gap: 0;
    }
    .saver-pack-launcher__pulse {
        border-radius: 50%;
    }
    /* Hide text + chevron; keep only the star icon */
    .saver-pack-launcher__text,
    .saver-pack-launcher__chevron {
        display: none;
    }

    .saver-pack-sheet {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        border-radius: 18px 18px 0 0;
        padding-top: 6px;
        transform: translateY(110%);
        max-height: 80vh;
        overflow-y: auto;
    }
    .saver-pack-widget[data-state="open"] .saver-pack-sheet {
        transform: translateY(0);
    }
    .saver-pack-widget[data-state="open"] .saver-pack-launcher {
        opacity: 0;
        pointer-events: none;
    }
    .saver-pack-sheet__handle { display: block; }
}
