/* Combo builder popup (shop/inc/popup_combo_builder.php + js/combo-builder.js) */
.combo-builder-popup{
    --cb-bg:#fffdfa;
    --cb-text:#392719;
    --cb-muted:#796859;
    --cb-line:#e5dacf;
    --cb-soft:#f3ebe1;
    --cb-accent:#452712;
    --cb-on-accent:#fff;
    --cb-pill:#f6dedb;
    --cb-pill-text:#7a2e22;
    --cb-green:#587145;
    --cb-green-soft:#eef2e8;
    --cb-gap:22px;
    max-width:960px;
    background:var(--cb-bg);
    color:var(--cb-text);
    border-radius:24px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
    max-height:calc(100vh - 30px);
    max-height:calc(100dvh - 30px);
}
.combo-builder-popup .combo_builder_output{display:flex;flex-direction:column;flex:0 1 auto;min-height:0}
.popup-content .popup-container.combo-builder-popup > .btn-close{position:absolute;right:10px;top:10px;z-index:3;background:var(--cb-bg);transform:translateZ(0)}
.combo-builder{position:relative;display:flex;flex-direction:column;flex:0 1 auto;min-height:0;font-family:var(--font-primary);text-align:left}
.combo-builder *{box-sizing:border-box}
.combo-builder button{font-family:inherit;color:inherit;cursor:pointer}
.combo-builder button:disabled{opacity:.4;cursor:default}

.combo-builder__main{flex:0 1 auto;min-height:0;overflow-y:auto;scrollbar-width:thin;scrollbar-color:#d9c6b4 transparent;overscroll-behavior:contain;padding:28px var(--cb-gap) 18px}
.combo-builder[data-stage="size"] .combo-builder__main > *,
.combo-builder[data-stage="review"] .combo-builder__main > *{max-width:560px;margin-left:auto;margin-right:auto}
.combo-builder__footer{flex-shrink:0;background:var(--cb-bg);border-top:1px solid var(--cb-line);padding:16px var(--cb-gap) 18px}
.combo-builder[data-stage="size"] .combo-builder__footer > *,
.combo-builder[data-stage="review"] .combo-builder__footer > *{max-width:560px;margin-left:auto;margin-right:auto}
.combo-builder__live{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}

/* typography */
.combo-builder .cb-eyebrow{font-size:11px;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;color:#9a6b44;margin-bottom:10px}
.combo-builder .cb-title{font-family:var(--font-secondary);font-size:30px;line-height:1.15;letter-spacing:0;font-weight:900;color:var(--cb-text);margin:0 0 12px;padding-right:36px}
.combo-builder .cb-text{font-size:14px;line-height:1.55;color:var(--cb-muted);margin:0 0 20px}

/* buttons */
.combo-builder .cb-primary,
.combo-builder .cb-secondary{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:54px;padding:12px 20px;border-radius:12px;font-size:16px;font-weight:700;border:2px solid var(--cb-accent);transition:opacity .2s,background .2s}
.combo-builder .cb-primary{background:var(--cb-accent);color:var(--cb-on-accent)}
.combo-builder .cb-secondary{background:var(--cb-bg);color:var(--cb-accent)}
.combo-builder .cb-primary.loading{opacity:.6;pointer-events:none}
.combo-builder .cb-primary_small{min-height:46px;font-size:14px;justify-content:center}
.combo-builder .cb-arrow{font-size:20px;line-height:1}
.combo-builder .cb-back{display:inline-block;border:0;background:none;padding:0;margin:0 0 14px;font-size:13px;color:var(--cb-muted)}
.combo-builder .cb-back:hover,.combo-builder .cb-link:hover{color:var(--cb-accent)}
.combo-builder .cb-link{border:0;background:none;padding:6px 4px;font-size:13px;color:var(--cb-muted);white-space:nowrap}
.combo-builder .cb-pill{flex-shrink:0;padding:6px 10px;border-radius:8px;background:var(--cb-pill);color:var(--cb-pill-text);font-size:16px;font-weight:800}
.combo-builder .cb-discount{font-size:15px;font-weight:800;color:#9a5a3a}

/* progress */
.combo-builder .cb-progress{display:flex;gap:8px;margin:0 0 16px}
.combo-builder .cb-progress i{flex:1;height:5px;border-radius:3px;background:var(--cb-soft)}
.combo-builder .cb-progress i.cb-filled{background:#b07a55}
.combo-builder .cb-progress_steps i.cb-filled{background:var(--cb-accent)}
.combo-builder .cb-progress_steps{margin-bottom:22px;padding-right:36px}

/* step 1: sizes */
.combo-builder .cb-sizes{display:grid;gap:10px;margin-bottom:16px}
.combo-builder .cb-size{display:flex;align-items:center;gap:14px;width:100%;padding:16px 18px;text-align:left;background:var(--cb-bg);border:1px solid var(--cb-line);border-radius:14px;transition:border-color .2s,background .2s}
.combo-builder .cb-size:hover{border-color:#c9b4a0}
.combo-builder .cb-size[aria-pressed="true"]{background:#f8ecdf;border:2px solid var(--cb-accent);padding:15px 17px}
.combo-builder .cb-size__radio{flex-shrink:0;width:22px;height:22px;border-radius:50%;border:1.5px solid #b9a898;position:relative}
.combo-builder .cb-size[aria-pressed="true"] .cb-size__radio{background:var(--cb-accent);border-color:var(--cb-accent)}
.combo-builder .cb-size[aria-pressed="true"] .cb-size__radio::after{content:"";position:absolute;left:7px;top:3px;width:5px;height:10px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg)}
.combo-builder .cb-size__text{flex:1;min-width:0}
.combo-builder .cb-size strong{display:block;font-size:19px;font-weight:900}
.combo-builder .cb-size small{display:block;margin-top:3px;font-size:12px;color:var(--cb-muted)}
.combo-builder .cb-size[aria-pressed="true"] .cb-pill{background:#ecd5bf;color:var(--cb-accent)}
.combo-builder .cb-hint{padding:14px 16px;border-radius:12px;background:var(--cb-soft);font-size:13px;line-height:1.45;color:var(--cb-muted)}

/* step 2: catalog */
.combo-builder .cb-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;font-size:15px}
.combo-builder .cb-slots{display:grid;gap:8px;margin-bottom:18px;max-width:560px}
.combo-builder .cb-slots_wide{max-width:none}
.combo-builder .cb-slot{position:relative;min-width:0;min-height:68px;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:4px;border:1px dashed var(--cb-line);border-radius:12px;font-size:11px;color:var(--cb-muted);text-align:center}
.combo-builder .cb-slot_filled{border:1px solid var(--cb-line);background:var(--cb-soft)}
.combo-builder .cb-slot img{width:100%;height:46px;object-fit:contain}
.combo-builder .cb-slot small{font-size:10px;line-height:1.2;margin-top:1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
.combo-builder .cb-slot__name{display:block;max-width:100%;margin-top:2px;font-size:10px;font-weight:600;line-height:1.2;color:var(--cb-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.combo-builder .cb-slot__remove{position:absolute;right:-6px;top:-6px;width:24px;height:24px;padding:0;border:1px solid var(--cb-line);border-radius:50%;background:var(--cb-bg);font-size:15px;line-height:1}
.combo-builder .cb-sticky{position:sticky;top:-28px;z-index:2;margin:-10px calc(-1 * var(--cb-gap)) 0;padding:10px var(--cb-gap) 0;background:var(--cb-bg);transition:box-shadow .2s;border-bottom-left-radius:20px;border-bottom-right-radius:20px}
.combo-builder .cb-sticky .cb-head,.combo-builder .cb-sticky .cb-progress{padding-right:36px}
.combo-builder .cb-slot,.combo-builder .cb-slot img,.combo-builder .cb-progress,.combo-builder .cb-slots,.combo-builder .cb-tabs,.combo-builder .cb-tab{transition:min-height .2s,height .2s,margin .2s,padding .2s}
.combo-builder.cb-compact .cb-sticky{box-shadow:0 8px 10px -10px rgba(57,39,25,.35)}
.combo-builder.cb-compact .cb-sticky{padding-top:22px}
.combo-builder.cb-compact .cb-head{margin-bottom:6px}
.combo-builder.cb-compact .cb-progress{margin-bottom:10px}
.combo-builder.cb-compact .cb-slots{margin-bottom:10px}
.combo-builder.cb-compact .cb-slot{min-height:54px}
.combo-builder.cb-compact .cb-slot img{height:34px}
.combo-builder.cb-compact .cb-tabs{margin-bottom:10px}
.combo-builder.cb-compact .cb-tab{min-height:34px;padding:6px 14px}
.combo-builder .cb-back_pinned{display:none;margin-bottom:8px}
.combo-builder.cb-compact .cb-back_pinned{display:inline-block}
.combo-builder.cb-notrans *{transition:none !important}
.combo-builder .cb-tabs{display:flex;gap:8px;overflow-x:auto;margin:0 calc(-1 * var(--cb-gap)) 14px;padding:0 var(--cb-gap) 8px;scrollbar-width:none}
.combo-builder .cb-tabs::-webkit-scrollbar{display:none}
.combo-builder .cb-tab{flex-shrink:0;min-height:38px;padding:8px 16px;border:0;border-radius:20px;background:var(--cb-soft);font-size:13px;font-weight:600;color:var(--cb-muted)}
.combo-builder .cb-tab[aria-pressed="true"]{background:var(--cb-accent);color:var(--cb-on-accent)}

.combo-builder .cb-section + .cb-section{margin-top:28px}
.combo-builder .cb-section__title{font-family:var(--font-secondary);font-size:22px;line-height:16px;font-weight:900;color:var(--cb-text);margin:0 0 12px}
.combo-builder .cb-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.combo-builder .cb-product{display:flex;flex-direction:column;min-width:0;padding:12px;border:1px solid var(--cb-line);border-radius:14px;background:var(--cb-bg);transition:background .2s,border-color .2s}
.combo-builder .cb-product_selected{background:#fbf3ea;border-color:#e2c9b2}
.combo-builder .cb-product__image{margin-bottom:8px}
.combo-builder .cb-product__image img{display:block;width:100%;height:96px;object-fit:cover}
.combo-builder .cb-product__name{font-size:15px;font-weight:700;line-height:1.25;margin-bottom:4px;cursor:pointer}
.combo-builder .cb-product__desc{font-size:11px;line-height:1.4;color:var(--cb-muted);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin-bottom:4px}
.combo-builder .cb-product__desc.is-open{display:block;-webkit-line-clamp:unset}
.combo-builder .cb-product__meta{font-size:11px;color:var(--cb-muted)}
.combo-builder .cb-product__bottom{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px;margin-top:auto;padding-top:8px}
.combo-builder .cb-product__price{font-size:15px;font-weight:800}
.combo-builder .cb-add{min-height:34px;padding:6px 12px;border:0;border-radius:8px;background:var(--cb-accent);color:var(--cb-on-accent);font-size:12px;font-weight:700}
.combo-builder .cb-qty{display:flex;align-items:center;gap:4px;background:#ecdfd2;border-radius:8px}
.combo-builder .cb-qty button{width:32px;height:34px;padding:0;border:0;background:none;font-size:18px;font-weight:700}
.combo-builder .cb-qty strong{min-width:14px;text-align:center;font-size:14px}

.combo-builder .cb-variants{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;border:0;padding:0;margin:12px 0 8px;min-width:0}
.combo-builder .cb-variants legend{font-size:12px;font-weight:700;margin-bottom:6px;padding:0}
.combo-builder .cb-variants label{position:relative;display:flex;flex-direction:column;align-items:flex-start;gap:4px;padding:8px 7px;border:1px solid var(--cb-line);border-radius:10px;font-size:12px;line-height:1.25;cursor:pointer;background:var(--cb-bg);min-width:0}
.combo-builder .cb-variants label:has(input:checked){border-color:var(--cb-accent);background:var(--cb-soft)}
.combo-builder .cb-variants input{position:absolute;width:1px;height:1px;margin:0;opacity:0;pointer-events:none}
.combo-builder .cb-variants label:has(input:focus-visible){outline:2px solid var(--cb-accent);outline-offset:2px}
.combo-builder .cb-variants span{min-width:0;max-width:100%;hyphens:auto}
.combo-builder .cb-variants small{display:block;font-size:11px;color:var(--cb-muted);margin-top:3px}
.combo-builder .cb-variants b{font-size:12px;white-space:nowrap}
.combo-builder .cb-variants__count{font-style:normal;font-size:11px;color:var(--cb-green);font-weight:700}
.combo-builder .cb-variants__actions{display:flex;align-items:center;gap:4px}
.combo-builder .cb-variants__actions .cb-primary_small{min-height:38px;padding:8px 10px;font-size:12px;line-height:1.2;border-radius:8px}
.combo-builder .cb-variants__actions .cb-link{font-size:20px;line-height:1;padding:6px}
.combo-builder .cb-note{margin-top:12px;font-size:12px;color:var(--cb-muted)}

/* catalog footer */
.combo-builder .cb-summary{margin-bottom:12px}
.combo-builder .cb-summary__label{font-size:12px;color:var(--cb-muted);margin-bottom:4px}
.combo-builder .cb-summary__row{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
.combo-builder .cb-summary s{font-size:13px;color:var(--cb-muted);font-weight:600}
.combo-builder .cb-summary strong{font-size:26px;font-weight:800}
.combo-builder .cb-saving{color:var(--cb-green);font-size:13px;margin-left:auto;font-weight:600}

/* step 3: review */
.combo-builder .cb-success{padding:12px 14px;border-radius:10px;background:var(--cb-green-soft);color:var(--cb-green);font-size:13px;font-weight:700;margin-bottom:8px}
.combo-builder .cb-row{display:flex;align-items:center;gap:14px;padding:14px 0;border-bottom:1px solid var(--cb-line)}
.combo-builder .cb-row img{flex-shrink:0;width:72px;height:52px;object-fit:contain}
.combo-builder .cb-row__text{flex:1;min-width:0}
.combo-builder .cb-row__name{font-size:15px;font-weight:700}
.combo-builder .cb-row small{display:block;margin-top:4px;font-size:12px;color:var(--cb-muted)}
.combo-builder .cb-totals{margin-top:18px}
.combo-builder .cb-total{display:flex;justify-content:space-between;gap:10px;margin-bottom:10px;font-size:14px;color:var(--cb-muted)}
.combo-builder .cb-total.cb-saving{margin-left:0;font-size:14px;color:var(--cb-green)}
.combo-builder .cb-total_big{padding-top:14px;margin-top:4px;border-top:1px solid var(--cb-line);color:var(--cb-text);font-size:22px;font-weight:800;margin-bottom:4px}
.combo-builder .cb-total-note{font-size:12px;color:var(--cb-green)}
.combo-builder .cb-footer-note{margin-top:8px;font-size:12px;color:var(--cb-muted)}

@media (min-width:768px){
    .combo-builder-popup{--cb-gap:32px}
    .combo-builder .cb-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
    .combo-builder .cb-product__image img{height:130px}
    .combo-builder .cb-product__desc{font-size:12px}
    .combo-builder .cb-slot__name{font-size:12px}
    .combo-builder[data-stage="catalog"] .combo-builder__footer{display:flex;align-items:center;justify-content:space-between;gap:24px}
    .combo-builder[data-stage="catalog"] .cb-summary{margin-bottom:0}
    .combo-builder[data-stage="catalog"] .combo-builder__footer > button{width:auto;min-width:300px}
}
@media (min-width:1024px){
    .combo-builder .cb-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}
@media (max-width:575px){
    #product-combo-builder{padding:0;align-items:stretch}
    .combo-builder-popup{border-radius:0;height:100vh;height:100dvh;max-height:none}
    .combo-builder-popup .combo_builder_output,.combo-builder-popup .combo-builder,.combo-builder-popup .combo-builder__main{flex-grow:1}
    .combo-builder-popup{--cb-gap:16px}
    .combo-builder .cb-title{font-size:26px}
    /* the close button gets its own top strip, so nothing (pinned or scrolling) can ever slide under it */
    .combo-builder-popup{padding-top:60px}
    .combo-builder__main{padding-top:10px}
    .combo-builder .cb-sticky,.combo-builder.cb-compact .cb-sticky{top:-10px;padding-top:10px}
    .popup-content .popup-container.combo-builder-popup > .btn-close{width:44px;height:44px;right:10px;top:10px}
    .combo-builder .cb-progress_steps,.combo-builder .cb-title,.combo-builder .cb-sticky .cb-head,.combo-builder .cb-sticky .cb-progress{padding-right:0}
    /* catalog: no empty strip, the close button sits next to the (shorter) progress bar instead */
    .combo-builder-popup:has(.combo-builder[data-stage="catalog"]){padding-top:0}
    .combo-builder[data-stage="catalog"] .cb-title,.combo-builder .cb-sticky .cb-head,.combo-builder .cb-sticky .cb-progress{padding-right:50px}
    .combo-builder .cb-sticky,.combo-builder.cb-compact .cb-sticky{padding-top:14px}
    /* compact footer */
    .combo-builder__footer{padding:10px var(--cb-gap) 12px}
    .combo-builder .cb-summary{margin-bottom:8px}
    .combo-builder .cb-summary__label{font-size:11px;margin-bottom:0}
    .combo-builder .cb-summary strong{font-size:22px}
    .combo-builder .cb-primary,.combo-builder .cb-secondary{min-height:46px;padding:8px 16px;font-size:15px}
    /* logged-in admins: the WP admin bar (z-index 99999) otherwise sits on top of the close button */
    .admin-bar .popup-wrapper:has(#product-combo-builder.active){z-index:100000}
}

/* shown only when the popup is opened before the prefetched data arrived */
.combo-builder_loading{display:flex;align-items:center;justify-content:center;min-height:420px}
.combo-builder .cb-loader{width:38px;height:38px;border-radius:50%;border:3px solid var(--cb-soft);border-top-color:var(--cb-accent);animation:cb-spin .8s linear infinite}
@keyframes cb-spin{to{transform:rotate(360deg)}}
.combo-builder__main::-webkit-scrollbar{width:6px}
.combo-builder__main::-webkit-scrollbar-track{background:transparent}
.combo-builder__main::-webkit-scrollbar-thumb{background:#d9c6b4;border-radius:3px}
