/* ══════════════════════════════════════════════
   WooCommerce Buy More Save More — Front CSS
   ══════════════════════════════════════════════ */

:root {
    --wbmsm-sale: #e53e3e;
    --wbmsm-bg: #ffffff;
    --wbmsm-border-active: #222222;
    --wbmsm-text: #333333;
    --wbmsm-text-size: 14px;
}

/* ── Base / Wrapper ── */
.wbmsm-wrap {
    margin: 1.5em 0;
    width: 100%;
    font-size: var(--wbmsm-text-size);
    color: var(--wbmsm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    box-sizing: border-box;
}
.wbmsm-wrap *, .wbmsm-wrap *::before, .wbmsm-wrap *::after {
    box-sizing: border-box;
}

/* ── Header ── */
.wbmsm-header {
    text-align: center;
    position: relative;
    margin-bottom: 0.6em;
}
.wbmsm-header::before,
.wbmsm-header::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 20%;
    height: 1px;
    background: #ccc;
}
.wbmsm-header::before { left: 0; }
.wbmsm-header::after  { right: 0; }
.wbmsm-header span {
    display: inline-block;
    padding: 0 0.8em;
    font-size: 0.88em;
    font-style: italic;
    color: #666;
    letter-spacing: 0.02em;
}

/* ── Hidden radio ── */
.wbmsm-tier input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* ── Callout badge (generic) ── */
.wbmsm-callout {
    position: absolute;
    top: -10px;
    right: 14px;
    background: #333;
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 2;
}
.wbmsm-callout-ribbon {
    right: auto;
    left: -6px;
    top: 10px;
    border-radius: 0 4px 4px 0;
    background: var(--wbmsm-sale);
}
.wbmsm-callout-pill {
    border-radius: 20px;
    background: var(--wbmsm-sale);
    top: -8px;
    right: 10px;
    font-size: 0.64em;
    padding: 2px 12px;
}

/* ── Prices (shared) ── */
.wbmsm-price-now {
    font-weight: 700;
    font-size: 1.15em;
    color: var(--wbmsm-text);
}
.wbmsm-price-was {
    font-size: 0.82em;
    color: #aaa;
    text-decoration: line-through;
    margin-left: 0.3em;
}

/* ── Custom radio circle (shared) ── */
.wbmsm-radio {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 50%;
    position: relative;
    display: inline-block;
    transition: border-color 0.2s;
}
.wbmsm-tier--active .wbmsm-radio {
    border-color: var(--wbmsm-border-active);
}
.wbmsm-tier--active .wbmsm-radio::after {
    content: "";
    position: absolute;
    top: 4px; left: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--wbmsm-border-active);
}

/* ── Tier info (shared) ── */
.wbmsm-tier-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    min-width: 0;
}
.wbmsm-tier-title {
    font-weight: 700;
    font-size: 1.05em;
}
.wbmsm-tier-sub {
    font-size: 0.82em;
    color: #777;
}
.wbmsm-tier-price {
    flex-shrink: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.1em;
}

/* ════════════════════════════
   1. LIST TEMPLATE
   ════════════════════════════ */
.wbmsm-tpl-list {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
.wbmsm-tier-list {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85em;
    padding: 1em 1.2em;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
.wbmsm-tier-list:hover { border-color: #bbb; }
.wbmsm-tier-list.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    box-shadow: 0 0 0 1px var(--wbmsm-border-active);
}

/* ════════════════════════════
   2. TABLE TEMPLATE
   ════════════════════════════ */
.wbmsm-tpl-table {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}
.wbmsm-tier-table {
    position: relative;
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(120px, 1.5fr) minmax(90px, 1fr) minmax(100px, 1.2fr);
    align-items: center;
    padding: 0.85em 1.1em;
    cursor: pointer;
    background: var(--wbmsm-bg);
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
    gap: 0.5em;
}
.wbmsm-tier-table:last-child { border-bottom: none; }
.wbmsm-tier-table:hover { background: #f7f7f7; }
.wbmsm-tier-table.wbmsm-tier--active {
    background: #f0f8ff;
    box-shadow: inset 3px 0 0 var(--wbmsm-border-active);
}
.wbmsm-table-qty { font-weight: 700; }
.wbmsm-table-discount { font-size: 0.85em; color: var(--wbmsm-sale); }
.wbmsm-table-unit { font-size: 0.85em; color: #666; }
.wbmsm-table-total { text-align: right; }

/* ════════════════════════════
   3. GRID TEMPLATE
   ════════════════════════════ */
.wbmsm-tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.7em;
}
.wbmsm-tier-grid {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.4em 1em;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: border-color 0.2s, transform 0.15s;
    gap: 0.4em;
}
.wbmsm-tier-grid:hover {
    border-color: #bbb;
    transform: translateY(-2px);
}
.wbmsm-tier-grid.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    box-shadow: 0 0 0 1px var(--wbmsm-border-active);
}
.wbmsm-grid-qty {
    font-size: 1.8em;
    font-weight: 800;
    color: var(--wbmsm-border-active);
}
.wbmsm-grid-price { font-weight: 700; font-size: 1.1em; }
.wbmsm-grid-unit { font-size: 0.78em; color: #888; }

/* ════════════════════════════
   4–5. CARD TEMPLATE (with optional image)
   ════════════════════════════ */
.wbmsm-tpl-card,
.wbmsm-tpl-card-image {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
}
.wbmsm-tier-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.9em;
    padding: 1em 1.2em;
    border: 2px solid #e5e5e5;
    border-radius: 14px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
.wbmsm-tier-card:hover { border-color: #bbb; }
.wbmsm-tier-card.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.wbmsm-card-img {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    overflow: hidden;
}
.wbmsm-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.wbmsm-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    min-width: 0;
}
.wbmsm-card-prices { margin-top: 0.3em; }
.wbmsm-card-check {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    color: #ccc;
    transition: color 0.2s;
}
.wbmsm-tier-card.wbmsm-tier--active .wbmsm-card-check {
    color: var(--wbmsm-border-active);
}
.wbmsm-check-mark {
    opacity: 0;
    transition: opacity 0.2s;
}
.wbmsm-tier-card.wbmsm-tier--active .wbmsm-check-mark {
    opacity: 1;
}

/* ════════════════════════════
   6. CARD TEMPLATE 1 (horizontal bold)
   ════════════════════════════ */
.wbmsm-tpl-card-tpl-1 {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
.wbmsm-tier-cardtpl1 {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 1em 1.2em;
    border: 2px solid #e5e5e5;
    border-radius: 14px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
    width: 100%;
}
.wbmsm-tier-cardtpl1:hover { border-color: #bbb; }
.wbmsm-tier-cardtpl1.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.wbmsm-ct1-left {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wbmsm-tier-cardtpl1.wbmsm-tier--active .wbmsm-ct1-left {
    background: var(--wbmsm-border-active);
}
.wbmsm-ct1-qty {
    font-size: 1.2em;
    font-weight: 800;
    color: #555;
}
.wbmsm-tier-cardtpl1.wbmsm-tier--active .wbmsm-ct1-qty {
    color: #fff;
}
.wbmsm-ct1-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    min-width: 0;
}
.wbmsm-ct1-save {
    font-size: 0.78em;
    color: var(--wbmsm-sale);
    font-weight: 600;
}
.wbmsm-ct1-right {
    flex-shrink: 0;
    text-align: right;
    display: flex;
    flex-direction: column;
}

/* ════════════════════════════
   7. CARD TEMPLATE 2 (centered vertical)
   ════════════════════════════ */
.wbmsm-tpl-card-tpl-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.7em;
}
.wbmsm-tier-cardtpl2 {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.6em 1em 1.2em;
    border: 2px solid #e5e5e5;
    border-radius: 14px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: all 0.2s;
    gap: 0.35em;
}
.wbmsm-tier-cardtpl2:hover {
    border-color: #bbb;
    transform: translateY(-2px);
}
.wbmsm-tier-cardtpl2.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-3px);
}
.wbmsm-ct2-badge {
    display: inline-block;
    background: var(--wbmsm-sale);
    color: #fff;
    font-size: 0.74em;
    font-weight: 700;
    padding: 2px 12px;
    border-radius: 20px;
    margin-bottom: 0.3em;
}
.wbmsm-ct2-qty {
    font-size: 1.2em;
    font-weight: 700;
}
.wbmsm-ct2-unit {
    font-size: 0.78em;
    color: #888;
}

/* ════════════════════════════
   8. CARD TEMPLATE 3 (minimal pill)
   ════════════════════════════ */
.wbmsm-tpl-card-tpl-3 {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}
.wbmsm-tier-cardtpl3 {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.9em 1.2em;
    border: 2px solid #e5e5e5;
    border-radius: 24px;
    cursor: pointer;
    background: var(--wbmsm-bg);
    transition: all 0.2s;
    gap: 0.25em;
    width: 100%;
}
.wbmsm-tier-cardtpl3:hover { border-color: #bbb; }
.wbmsm-tier-cardtpl3.wbmsm-tier--active {
    border-color: var(--wbmsm-border-active);
    background: #fafafa;
}
.wbmsm-ct3-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wbmsm-ct3-qty { font-weight: 700; font-size: 1.02em; }
.wbmsm-ct3-prices { display: flex; align-items: baseline; gap: 0.4em; }
.wbmsm-ct3-per { font-size: 0.78em; color: #888; }

/* ════════════════════════════
   RESPONSIVE
   ════════════════════════════ */
@media (max-width: 480px) {
    .wbmsm-tpl-grid,
    .wbmsm-tpl-card-tpl-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    .wbmsm-tier-table {
        grid-template-columns: 1fr 1fr;
        gap: 0.3em;
    }
    .wbmsm-table-unit { display: none; }
}
