/* Zwibits Bundle Builder Pro — Frontend CSS (fully self-contained) */
/* All values driven by CSS custom properties set via inline style on the block wrapper */

.zwbb-fe-builder {
    --zwbb-from: #c6fc00;
    --zwbb-to:   #a3d900;
    --zwbb-btn-bg: #c6fc00;
    --zwbb-btn-txt: #111;
    --zwbb-btn-rad: 8px;
    --zwbb-btn-border: none;
    --zwbb-card-bg: #fff;
    --zwbb-card-rad: 12px;
    --zwbb-card-bc: #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    color: #111;
    box-sizing: border-box;
    position: relative;
}
.zwbb-fe-builder *, .zwbb-fe-builder *::before, .zwbb-fe-builder *::after { box-sizing: border-box; }

/* ── Header ─────────────────────────────────────────────────── */
.zwbb-fe-header { text-align: center; padding: 1.5rem 1rem 1rem; }
.zwbb-fe-title  { font-size: 1.6em; font-weight: 800; margin: 0 0 .4rem; color: #111; }

/* ── Progress bar wrap ──────────────────────────────────────── */
.zwbb-fe-progress-wrap { padding: .5rem 1.5rem 1rem; }
.zwbb-fe-tier-msg { text-align: center; font-size: .875em; font-weight: 700; min-height: 1.5em; margin-bottom: .5rem; color: #374151; }

/* Style A — smooth gradient with floating bubble */
.zwbb-fe-pb-track { position: relative; height: 14px; background: #e5e7eb; border-radius: 7px; overflow: visible; }
.zwbb-fe-pb-fill  { position: absolute; left: 0; top: 0; height: 100%; border-radius: 7px; min-width: 0;
    background: linear-gradient(90deg, var(--zwbb-from), var(--zwbb-to));
    transition: width .5s cubic-bezier(.4,0,.2,1); overflow: visible; }
.zwbb-fe-pb-bubble { position: absolute; right: -16px; top: -32px; background: white;
    border: 2px solid var(--zwbb-from); color: #111; font-size: 11px; font-weight: 800;
    width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.zwbb-fe-pb-bubble::after { content:''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: var(--zwbb-from); }

/* Style B — dotted beads in pill */
.zwbb-fe-pb-pill { border: 2px solid var(--zwbb-from); border-radius: 100px; padding: 5px 10px;
    background: transparent; }
.zwbb-fe-pb-dots { display: flex; align-items: center; gap: 3px; width: 100%; flex-wrap: nowrap; }
.zwbb-fe-pb-dot  { flex: 1; height: 12px; border-radius: 6px; min-width: 0; background: #e5e7eb; transition: background .4s; }
.zwbb-fe-pb-dot.active { background: linear-gradient(90deg, var(--zwbb-from), var(--zwbb-to)); }

/* Style C — gradient fill in outlined pill */
.zwbb-fe-pb-pill--outline { position: relative; height: 22px; border: 2px solid var(--zwbb-from); border-radius: 100px; overflow: hidden; padding: 0; }
.zwbb-fe-pb-fill-pill { position: absolute; left: 0; top: 0; height: 100%;
    background: linear-gradient(90deg, var(--zwbb-from), var(--zwbb-to));
    border-radius: 100px; transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ── Sections ───────────────────────────────────────────────── */
.zwbb-fe-section { margin-bottom: 2.5rem; }
.zwbb-fe-section.skipped { opacity: .35; pointer-events: none; }
.zwbb-fe-section-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 8px; }
.zwbb-fe-section-title-group { display: flex; align-items: flex-start; gap: 10px; }
.zwbb-fe-sec-title   { margin: 0; font-size: 1.05em; font-weight: 800; color: #111; }
.zwbb-fe-sec-sub     { margin: 3px 0 0; font-size: .82em; color: #6b7280; }
.zwbb-fe-section-meta{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zwbb-fe-sec-limit   { font-size: .75em; background: #f3f4f6; color: #6b7280; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.zwbb-fe-skip-btn    { font-size: .8em; padding: 5px 14px; border-radius: 20px; cursor: pointer;
    border: 1.5px solid #d1d5db; background: #fff; font-family: inherit; transition: background .15s, border-color .15s; }
.zwbb-fe-skip-btn:hover, .zwbb-fe-skip-btn.active { background: #f9fafb; border-color: #9ca3af; }

/* ── Card grid ──────────────────────────────────────────────── */
.zwbb-fe-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.zwbb-fe-hidden { display: none !important; }

/* ── Product card ───────────────────────────────────────────── */
.zwbb-fe-card {
    background: var(--zwbb-card-bg);
    border: 1.5px solid var(--zwbb-card-bc);
    border-radius: var(--zwbb-card-rad);
    overflow: hidden; cursor: pointer; position: relative;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.zwbb-fe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.09); }
.zwbb-fe-card.selected {
    border-color: var(--zwbb-from);
    background: color-mix(in srgb, var(--zwbb-from) 8%, white);
    border-width: 2px;
}
.zwbb-fe-card-check {
    position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: var(--zwbb-from); color: #111;
}
.zwbb-fe-card.selected .zwbb-fe-card-check { display: flex; }
.zwbb-fe-card-img { width: 100%; aspect-ratio: 1; overflow: hidden; background: #f8f9fb; }
.zwbb-fe-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zwbb-fe-card-body { padding: 10px 12px 14px; }
.zwbb-fe-card-name  { font-size: .85em; font-weight: 700; line-height: 1.35; margin-bottom: 4px; color: #111; }
.zwbb-fe-card-desc  { font-size: .75em; color: #6b7280; line-height: 1.4; margin-bottom: 5px; }
.zwbb-fe-card-price { font-size: .95em; font-weight: 800; color: #111; margin-bottom: 10px; }
.zwbb-fe-qty-row    { display: flex; align-items: center; gap: 10px; }
.zwbb-fe-qb {
    width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #d1d5db;
    background: #fff; cursor: pointer; font-size: 16px; display: flex; align-items: center;
    justify-content: center; line-height: 1; font-family: inherit; padding: 0;
    transition: background .1s, border-color .1s;
}
.zwbb-fe-qb:hover { background: #f3f4f6; border-color: #9ca3af; }
.zwbb-fe-qn { font-size: .9em; font-weight: 800; min-width: 20px; text-align: center; }

/* ── Show more ──────────────────────────────────────────────── */
.zwbb-fe-show-more {
    width: 100%; margin-top: 10px; padding: 8px; font-size: .85em; cursor: pointer;
    background: transparent; border: 1.5px dashed #d1d5db; border-radius: 8px;
    font-family: inherit; transition: background .15s; color: #6b7280;
}
.zwbb-fe-show-more:hover { background: #f9fafb; }

/* ── Divider ────────────────────────────────────────────────── */
.zwbb-fe-divider { position: relative; margin: 24px 0; }
.zwbb-fe-divider-label {
    display: block; font-size: .8em; font-weight: 700; color: #6b7280;
    background: #fff; padding: 0 12px; position: relative; z-index: 1;
}
.zwbb-fe-divider[style*="border"] .zwbb-fe-divider-label {
    display: inline-block; position: absolute; top: 50%; transform: translateY(-50%);
}
.zwbb-fe-divider .zwbb-fe-divider-label[style*="text-align: center"],
.zwbb-fe-divider .zwbb-fe-divider-label[style*="text-align:center"] { left: 50%; transform: translateX(-50%) translateY(-50%); }
.zwbb-fe-divider .zwbb-fe-divider-label[style*="text-align: right"],
.zwbb-fe-divider .zwbb-fe-divider-label[style*="text-align:right"] { right: 0; left: auto; transform: translateY(-50%); }

/* ── Free product box ───────────────────────────────────────── */
.zwbb-fe-free-box {
    border: 2px dashed #d1d5db; border-radius: 14px; padding: 18px 20px;
    margin: 1.5rem 0; background: #fafafa; transition: border-color .3s, background .3s;
}
.zwbb-fe-free-box.unlocked {
    border-color: var(--zwbb-from); background: color-mix(in srgb, var(--zwbb-from) 6%, white);
}
.zwbb-fe-free-inner  { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.zwbb-fe-free-img    { position: relative; flex-shrink: 0; }
.zwbb-fe-free-img img{ width: 60px; height: 60px; border-radius: 10px; object-fit: cover; opacity: .45; transition: opacity .3s; }
.zwbb-fe-free-box.unlocked .zwbb-fe-free-img img { opacity: 1; }
.zwbb-fe-free-lock   { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.4em; transition: opacity .3s; }
.zwbb-fe-free-box.unlocked .zwbb-fe-free-lock { opacity: 0; pointer-events: none; }
.zwbb-fe-free-info   { flex: 1; min-width: 120px; }
.zwbb-fe-free-badge  { font-size: .7em; font-weight: 800; background: #111; color: var(--zwbb-from); padding: 2px 8px; border-radius: 20px; display: inline-block; margin-bottom: 5px; letter-spacing: .5px; }
.zwbb-fe-free-name   { font-size: .95em; font-weight: 700; color: #111; margin-bottom: 3px; }
.zwbb-fe-free-msg    { font-size: .8em; color: #6b7280; }
.zwbb-fe-free-btn {
    padding: 9px 18px; border-radius: 8px; font-size: .875em; font-weight: 700; cursor: pointer;
    border: 2px solid var(--zwbb-from); background: var(--zwbb-from); color: var(--zwbb-btn-txt);
    font-family: inherit; transition: opacity .2s; white-space: nowrap;
}
.zwbb-fe-free-btn:disabled { opacity: .4; cursor: not-allowed; background: #e5e7eb; border-color: #d1d5db; color: #9ca3af; }
.zwbb-fe-free-btn.added    { background: #dcfce7; border-color: #86efac; color: #15803d; cursor: default; }

/* ── Extra fields ───────────────────────────────────────────── */
.zwbb-fe-extra-fields { padding: 1.25rem; background: #f8f9fb; border-radius: 10px; border: 1px solid #e5e7eb; margin: 1.5rem 0; display: grid; gap: 12px; }
.zwbb-fe-field-group  { display: grid; gap: 6px; }
.zwbb-fe-field-label  { font-size: .85em; font-weight: 700; color: #374151; }
.zwbb-fe-input, .zwbb-fe-textarea {
    border: 1.5px solid #d1d5db; border-radius: 7px; padding: 8px 12px;
    font-size: .9em; font-family: inherit; width: 100%;
    transition: border-color .15s; outline: none; background: #fff;
}
.zwbb-fe-input:focus, .zwbb-fe-textarea:focus { border-color: var(--zwbb-from); }

/* ── Summary bar ────────────────────────────────────────────── */
.zwbb-fe-summary {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    padding: 14px 20px; background: #fff; border: 1.5px solid #e5e7eb; border-radius: 14px; margin-top: 1.5rem;
}
.zwbb-fe-summary--fixed {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 99999;
    border-radius: 0; border-left: none; border-right: none; border-bottom: none;
    box-shadow: 0 -4px 24px rgba(0,0,0,.1);
    margin-top: 0;
}
.zwbb-fe-summary-spacer { height: 80px; }
.zwbb-fe-summary-info   { display: flex; flex-direction: column; gap: 2px; }
.zwbb-fe-sum-label      { font-size: .72em; color: #6b7280; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.zwbb-fe-sum-total      { font-size: 1.5em; font-weight: 900; color: #111; }
.zwbb-fe-sum-sub        { font-size: .78em; color: #6b7280; }
.zwbb-fe-summary-actions{ display: flex; align-items: center; gap: 10px; }
.zwbb-fe-review-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: .75em 1.8em; font-size: 1em; font-weight: 800; cursor: pointer;
    border-radius: var(--zwbb-btn-rad); background: var(--zwbb-btn-bg);
    border: var(--zwbb-btn-border); color: var(--zwbb-btn-txt);
    font-family: inherit; transition: filter .15s, transform .1s;
}
.zwbb-fe-review-btn:hover { filter: brightness(.92); transform: translateY(-1px); }
.zwbb-fe-share-btn {
    background: #fff; border: 1.5px solid #e5e7eb; border-radius: 10px;
    padding: .65em .9em; font-size: 1.15em; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.zwbb-fe-share-btn:hover { background: #f9fafb; border-color: #d1d5db; }

/* ── Modal ──────────────────────────────────────────────────── */
.zwbb-fe-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 999999;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.zwbb-fe-modal {
    background: #fff; border-radius: 18px; padding: 2rem; max-width: 500px; width: 100%;
    max-height: 88vh; overflow-y: auto; position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.zwbb-fe-modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 1.6em; cursor: pointer; opacity: .4; line-height: 1; padding: 0; }
.zwbb-fe-modal-close:hover { opacity: 1; }
.zwbb-fe-modal-title { font-size: 1.2em; font-weight: 800; margin: 0 0 4px; }
.zwbb-fe-modal-sub   { font-size: .85em; color: #6b7280; margin: 0 0 1rem; }
.zwbb-fe-modal-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1rem; }
.zwbb-fe-order-item  { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1.5px solid #f3f4f6; border-radius: 10px; background: #fafafa; }
.zwbb-fe-order-thumb { width: 50px; height: 50px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: #f0f0f0; }
.zwbb-fe-order-thumb img { width: 100%; height: 100%; object-fit: cover; }
.zwbb-fe-order-info  { flex: 1; }
.zwbb-fe-order-name  { font-size: .875em; font-weight: 700; color: #111; }
.zwbb-fe-order-meta  { font-size: .75em; color: #6b7280; margin-top: 2px; }
.zwbb-fe-order-price { font-weight: 800; font-size: .9em; white-space: nowrap; color: #111; }
.zwbb-fe-modal-discount { background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 8px; padding: 8px 14px; font-size: .875em; font-weight: 700; color: #15803d; margin-bottom: .75rem; }
.zwbb-fe-modal-total-row { display: flex; justify-content: space-between; font-weight: 900; font-size: 1.1em; padding: .75rem 0 1rem; border-top: 1.5px solid #f3f4f6; color: #111; }
.zwbb-fe-modal-actions { display: flex; gap: 10px; }
.zwbb-fe-modal-back  { flex: 1; padding: .75em; border: 1.5px solid #e5e7eb; background: #f3f4f6; color: #111; border-radius: 9px; font-size: .9em; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s; }
.zwbb-fe-modal-back:hover { background: #f9fafb; }
.zwbb-fe-atc-btn {
    flex: 2; padding: .75em; border: var(--zwbb-btn-border);
    background: var(--zwbb-btn-bg); color: var(--zwbb-btn-txt);
    border-radius: var(--zwbb-btn-rad); font-size: .9em; font-weight: 800;
    cursor: pointer; font-family: inherit; transition: filter .15s;
}
.zwbb-fe-atc-btn:hover  { filter: brightness(.92); }
.zwbb-fe-atc-btn.loading{ opacity: .65; pointer-events: none; }

/* ── Notice toast ───────────────────────────────────────────── */
.zwbb-fe-notice {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
    background: #111; color: #fff; padding: 10px 22px; border-radius: 10px;
    z-index: 9999999; font-size: .9em; font-weight: 600; pointer-events: none;
    max-width: 90vw; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

/* ── Cart breakdown ─────────────────────────────────────────── */
.zwbb-cart-breakdown { margin: 6px 0 0; padding: 0; list-style: none; font-size: .8em; color: #6b7280; }
.zwbb-cart-breakdown li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #f3f4f6; }

/* ── color-mix fallback for older browsers ─────────────────── */
@supports not (background: color-mix(in srgb, red 10%, white)) {
    .zwbb-fe-card.selected { background: #f9fffe; }
    .zwbb-fe-free-box.unlocked { background: #f9fffe; }
}

/* ── CSS var additions ──────────────────────────────────────── */
.zwbb-fe-builder {
    --zwbb-btn-hbg: #b5e800;
    --zwbb-btn-htxt: #111;
    --zwbb-card-sel-bg: #f7ffe0;
    --zwbb-card-sel-bc: #c6fc00;
}

/* ── Tier milestone strip ───────────────────────────────────── */
.zwbb-fe-tier-strip { display:flex;align-items:flex-start;justify-content:center;padding:1rem 1rem .5rem;gap:0;overflow-x:auto;-webkit-overflow-scrolling:touch }
.zwbb-ts-node { display:flex;flex-direction:column;align-items:center;gap:4px;min-width:80px;max-width:120px;text-align:center;flex-shrink:0 }
.zwbb-ts-dot  { width:18px;height:18px;border-radius:50%;border:2.5px solid #d1d5db;background:#fff;transition:all .3s;flex-shrink:0 }
.zwbb-ts-val  { font-size:.7em;font-weight:800;color:#9ca3af;transition:color .3s }
.zwbb-ts-label{ font-size:.65em;color:#9ca3af;line-height:1.3;transition:color .3s;max-width:100px }
.zwbb-ts-line { flex:1;height:2.5px;background:#e5e7eb;margin-top:7px;min-width:12px;transition:background .3s }
.zwbb-ts-node.reached .zwbb-ts-dot  { background:var(--zwbb-from);border-color:var(--zwbb-from) }
.zwbb-ts-node.reached .zwbb-ts-val  { color:var(--zwbb-from) }
.zwbb-ts-node.reached .zwbb-ts-label{ color:#374151 }
.zwbb-ts-node.pending .zwbb-ts-dot  { border-color:var(--zwbb-from);animation:zwbb-pulse 1.2s infinite }
.zwbb-ts-node.pending .zwbb-ts-val  { color:var(--zwbb-from) }
@keyframes zwbb-pulse { 0%,100%{ box-shadow:0 0 0 0 color-mix(in srgb, var(--zwbb-from) 40%, transparent) } 50%{ box-shadow:0 0 0 6px transparent } }

/* ── Section title indicator ────────────────────────────────── */
.zwbb-fe-sec-title-wrap { display:flex;flex-direction:column;gap:3px }
.zwbb-fe-sec-title-wrap .zwbb-fe-sec-title { transition:color .2s }
.zwbb-fe-sec-title-wrap.has-selection .zwbb-fe-sec-title { color:var(--zwbb-from) }
.zwbb-fe-sec-title-wrap.has-selection::before { content:'✓';display:inline-block;margin-right:6px;color:var(--zwbb-from);font-weight:800 }

/* ── Skip button inherits button style ──────────────────────── */
.zwbb-fe-skip-btn {
    font-size:.8em;padding:6px 16px;border-radius:var(--zwbb-btn-rad);cursor:pointer;
    border:var(--zwbb-btn-border);background:var(--zwbb-btn-bg);color:var(--zwbb-btn-txt);
    font-family:inherit;transition:background .15s,color .15s;font-weight:600;
}
.zwbb-fe-skip-btn:hover,
.zwbb-fe-skip-btn.is-skipped { background:var(--zwbb-btn-hbg);color:var(--zwbb-btn-htxt) }

/* ── Button hover via CSS vars ──────────────────────────────── */
.zwbb-fe-review-btn:hover { background:var(--zwbb-btn-hbg);color:var(--zwbb-btn-htxt);filter:none;transform:translateY(-1px) }
.zwbb-fe-atc-btn:hover    { background:var(--zwbb-btn-hbg);color:var(--zwbb-btn-htxt);filter:none }

/* ── Plus/minus inherit button style ───────────────────────── */
.zwbb-fe-qb {
    width:28px;height:28px;border-radius:50%;
    border:var(--zwbb-btn-border)!important;
    background:var(--zwbb-btn-bg)!important;
    color:var(--zwbb-btn-txt)!important;
    cursor:pointer;font-size:16px;display:flex;align-items:center;justify-content:center;
    line-height:1;font-family:inherit;padding:0;transition:background .1s,color .1s;
}
.zwbb-fe-qb:hover { background:var(--zwbb-btn-hbg)!important;color:var(--zwbb-btn-htxt)!important }

/* ── Card selected state uses CSS vars ──────────────────────── */
.zwbb-fe-card.selected {
    border-color:var(--zwbb-card-sel-bc);
    background:var(--zwbb-card-sel-bg);
    border-width:2px;
}
.zwbb-fe-card-check { background:var(--zwbb-card-sel-bc);color:var(--zwbb-btn-txt) }

/* ── Image block / Spacer breakpoint visibility ─────────────── */
@media (min-width:1024px) { .zwbb-hide-desktop { display:none!important } }
@media (min-width:768px) and (max-width:1023px) { .zwbb-hide-tablet { display:none!important } }
@media (max-width:767px) { .zwbb-hide-mobile { display:none!important } }

/* ── Free product box (updated) ─────────────────────────── */
.zwbb-fe-free-badge-row { display:flex; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.zwbb-fe-free-badge { font-size:.7em; font-weight:800; background:#111; color:var(--zwbb-from); padding:3px 10px; border-radius:20px; white-space:nowrap; letter-spacing:.5px; }
.zwbb-fe-free-products { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.zwbb-fe-free-item { display:flex; flex-direction:column; align-items:center; gap:6px; max-width:90px; }
.zwbb-fe-free-img-wrap { position:relative; width:72px; height:72px; border-radius:10px; overflow:hidden; background:#f3f4f6; }
.zwbb-fe-free-img-wrap img { width:100%; height:100%; object-fit:cover; transition:opacity .3s; }
.zwbb-fe-free-lock { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:1.4em; background:rgba(255,255,255,.3); }
.zwbb-fe-free-name { font-size:.75em; font-weight:600; text-align:center; color:#374151; line-height:1.3; }
.zwbb-fe-free-box.unlocked .zwbb-fe-free-lock { display:none; }
.zwbb-fe-free-box.unlocked .zwbb-fe-free-msg { color:var(--zwbb-from); font-weight:700; }
