/**
 * Storelly B2B — admin slim layer.
 *
 * The B2B admin pages reuse the shared component library (storelly-admin-ui.css =
 * .spbwc-page-hero/.spbwc-block/.spbwc-stat-card/.spbwc-admin-table/.spbwc-empty-state…
 * and quotes-admin.css = .spbwc-q-detail/.spbwc-q-kpi/.spbwc-q-recap/.spbwc-q-timeline).
 * This file only adds the few B2B-specific atoms + status-pill variants on the
 * admin design tokens (_tokens.css → --st-*).
 */

/* ── Layout utilities (token-driven; replace inline styles) ── */
.spbwc-row { display: flex; align-items: center; gap: var(--nbd-space-3); flex-wrap: wrap; }
.spbwc-row--sm { gap: var(--nbd-space-2); }
.spbwc-row--tight { gap: var(--nbd-space-1); }
.spbwc-row--between { justify-content: space-between; }
.spbwc-row--end { justify-content: flex-end; }
.spbwc-row--top { align-items: flex-start; }
.spbwc-row--push { margin-right: auto; }
.spbwc-stack { display: flex; flex-direction: column; gap: var(--nbd-space-1); }
.spbwc-stack--end { align-items: flex-end; text-align: left; }
.spbwc-icon-xl { font-size: 32px; width: 32px; height: 32px; }
.spbwc-muted { color: var(--nbd-st-text-mute); }
.spbwc-muted-sm { color: var(--nbd-st-text-soft); font-size: var(--text-sm); }
.spbwc-amount { font-size: var(--text-3xl); font-weight: var(--font-bold); color: var(--st-brand-pressed); }
.spbwc-list__item-grow { flex: 1; min-width: 0; }
/* Compact input widths for inline forms */
.spbwc-input--xs { width: 90px; }
.spbwc-input--sm { width: 120px; }
.spbwc-input--md { width: 150px; }
.spbwc-input--mw-sm { max-width: 130px; }
.spbwc-input--mw-md { max-width: 220px; }
.spbwc-input--mw-lg { max-width: 260px; }
/* Mini key-value stat (recap cards) */
.spbwc-kv { display: flex; flex-direction: column; text-align: left; }
.spbwc-kv__v { font-size: var(--text-3xl); font-weight: var(--font-bold); color: var(--st-brand); line-height: 1.1; }
.spbwc-kv__l { font-size: var(--text-sm); color: var(--nbd-st-text-mute); text-transform: uppercase; letter-spacing: .04em; }

/* ── Customer-picker modal ───────────────────────────────── */
body.spbwc-modal-open { overflow: hidden; }
.spbwc-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh var(--nbd-space-4) var(--nbd-space-4);
}
.spbwc-modal[hidden] { display: none; }
.spbwc-modal__backdrop { position: absolute; inset: 0; background: var(--st-overlay, rgba(16, 24, 40, 0.55)); }
.spbwc-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: var(--nbd-st-bg);
    border-radius: var(--nbd-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: spbwc-modal-in 0.16s ease-out;
}
@keyframes spbwc-modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.spbwc-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--nbd-space-4) var(--nbd-space-5);
    border-bottom: 1px solid var(--nbd-st-border-light);
}
.spbwc-modal__head h2 { margin: 0; font-size: var(--text-2xl); }
.spbwc-modal__close {
    appearance: none; background: none; border: 0; cursor: pointer;
    font-size: 24px; line-height: 1; color: var(--nbd-st-text-mute); padding: 0 4px;
}
.spbwc-modal__close:hover { color: var(--nbd-st-text); }
.spbwc-modal__body { padding: var(--nbd-space-5); }
.spbwc-modal__body .spbwc-search-bar { max-width: none; margin-bottom: var(--nbd-space-3); }

.spbwc-picker__results { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.spbwc-picker__results li { margin: 0; }
.spbwc-picker__item {
    display: flex;
    align-items: center;
    gap: var(--nbd-space-3);
    padding: var(--nbd-space-2) var(--nbd-space-2);
    border-radius: var(--nbd-radius-md);
    text-decoration: none;
    color: var(--nbd-st-text);
}
.spbwc-picker__item:hover { background: var(--nbd-st-bg-soft); }
.spbwc-picker__meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.spbwc-picker__item .dashicons { color: var(--nbd-st-text-mute); }
.spbwc-picker__empty { padding: var(--nbd-space-4); color: var(--nbd-st-text-mute); text-align: center; }
.spbwc-picker__hint { margin-top: var(--nbd-space-3); }

/* Status pill variants used by SPBWC_B2B_Admin::status_pill(). */
.spbwc-pill {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: 1.6;
    border-radius: var(--nbd-radius-pill);
    padding: 2px 10px;
    vertical-align: middle;
    background: var(--st-pill-draft-bg);
    color: var(--st-pill-draft-text);
}
.spbwc-pill--success { background: var(--st-pill-active-bg);   color: var(--st-pill-active-text); }
.spbwc-pill--warn    { background: var(--st-pill-pending-bg);  color: var(--st-pill-pending-text); }
.spbwc-pill--danger  { background: var(--st-pill-danger-bg);   color: var(--st-pill-danger-text); }
.spbwc-pill--info    { background: var(--st-pill-featured-bg); color: var(--st-pill-featured-text); }
.spbwc-pill--off,
.spbwc-pill--neutral { background: var(--st-pill-draft-bg);    color: var(--st-pill-draft-text); }

/* ── Atom: tabs ──────────────────────────────────────────── */
.spbwc-tabs {
    display: flex;
    gap: var(--nbd-space-1);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--nbd-st-border-light);
    margin: var(--nbd-space-6) 0 var(--nbd-space-5);
}
.spbwc-tab {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: var(--nbd-space-2) var(--nbd-space-3);
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    color: var(--nbd-st-text-soft);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--nbd-space-1);
}
.spbwc-tab:hover { color: var(--st-brand); }
.spbwc-tab.is-active {
    color: var(--st-brand);
    border-bottom-color: var(--st-brand);
}
.spbwc-tab .count {
    background: var(--nbd-st-bg-soft);
    border-radius: var(--nbd-radius-pill);
    padding: 0 6px;
    font-size: var(--text-sm);
}
/* Detail panels: JS shows one at a time (instant switch, no reload); without
   JS every panel stays visible so the content is always reachable. */
.spbwc-b2b-detail.js .spbwc-b2b-panel { display: none; }
.spbwc-b2b-detail.js .spbwc-b2b-panel.is-active { display: block; }

/* ── Atom: avatar ────────────────────────────────────────── */
.spbwc-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--nbd-radius-pill);
    background: var(--st-brand-soft);
    color: var(--st-brand-pressed);
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    text-transform: uppercase;
    flex: 0 0 auto;
    overflow: hidden;
}
.spbwc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.spbwc-avatar--sm { width: 24px; height: 24px; font-size: var(--text-sm); }
.spbwc-avatar--lg { width: 44px; height: 44px; font-size: var(--text-lg); }

/* ── Atom: usage meter ───────────────────────────────────── */
.spbwc-meter {
    display: block;
    width: 100%;
    max-width: 160px;
    height: 6px;
    border-radius: var(--nbd-radius-pill);
    background: var(--nbd-st-border-subtle);
    overflow: hidden;
}
.spbwc-meter__fill {
    display: block;
    height: 100%;
    border-radius: var(--nbd-radius-pill);
    background: var(--nbd-color-success);
}
.spbwc-meter--warn .spbwc-meter__fill { background: var(--nbd-color-warning); }
.spbwc-meter--danger .spbwc-meter__fill { background: var(--nbd-color-danger); }
.spbwc-meter__label { font-size: var(--text-sm); color: var(--nbd-st-text-mute); }

/* ── Atom: role chip ─────────────────────────────────────── */
.spbwc-role-chip {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-radius: var(--nbd-radius-pill);
    padding: 2px 9px;
    background: var(--st-pill-draft-bg);
    color: var(--st-pill-draft-text);
}
.spbwc-role-chip--owner    { background: var(--st-pill-featured-bg); color: var(--st-pill-featured-text); }
.spbwc-role-chip--admin    { background: var(--st-brand-soft);      color: var(--st-brand-pressed); }
.spbwc-role-chip--approver { background: var(--st-pill-active-bg);  color: var(--st-pill-active-text); }
.spbwc-role-chip--requester{ background: var(--st-pill-pending-bg); color: var(--st-pill-pending-text); }
.spbwc-role-chip--viewer   { background: var(--st-pill-draft-bg);   color: var(--st-pill-draft-text); }

/* Neutral grey pill — for a bare .spbwc-block__badge on an unstyled block head. */
.spbwc-badge--neutral { background: var(--st-pill-draft-bg); color: var(--st-pill-draft-text); }

/* ── Members roster (company detail → Members tab) ───────── */
/* Logical properties below are direction-agnostic — identical in LTR/RTL. */
.spbwc-member-list { width: 100%; }

.spbwc-member-list__head {
    display: flex;
    align-items: center;
    gap: var(--nbd-space-3);
    padding: var(--nbd-space-2) var(--nbd-space-5);
    padding-inline-start: calc(var(--nbd-space-5) + 44px + var(--nbd-space-3));
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--nbd-st-text-mute);
    background: var(--nbd-st-bg-soft);
    border-bottom: 1px solid var(--nbd-st-border-subtle);
}
.spbwc-member-list__head .spbwc-member__role,
.spbwc-member-list__head .spbwc-member__limit { display: block; }

.spbwc-member.spbwc-list__item {
    padding-inline-start: var(--nbd-space-5);
    padding-inline-end: var(--nbd-space-5);
}
.spbwc-member.spbwc-list__item:hover {
    color: var(--nbd-st-text);
    background: var(--nbd-st-bg-soft);
}

.spbwc-member__id {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.spbwc-member__name {
    display: flex;
    align-items: center;
    gap: var(--nbd-space-2);
    min-width: 0;
    font-weight: var(--font-semibold);
    color: var(--nbd-st-text);
}
.spbwc-member__email {
    font-size: var(--text-sm);
    color: var(--nbd-st-text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spbwc-member__role  { flex: 0 0 130px; }
.spbwc-member__limit {
    flex: 0 0 120px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: end;
    line-height: 1.25;
}
.spbwc-member__limit-val  { font-weight: var(--font-semibold); color: var(--nbd-st-text); }
.spbwc-member__limit-unit { font-size: var(--text-xs); color: var(--nbd-st-text-mute); text-transform: uppercase; letter-spacing: 0.04em; }
.spbwc-member__limit-none { font-size: var(--text-sm); color: var(--nbd-st-text-mute); }

@media (max-width: 600px) {
    .spbwc-member-list__head { display: none; }
    .spbwc-member.spbwc-list__item { flex-wrap: wrap; }
    .spbwc-member__role,
    .spbwc-member__limit {
        flex: 0 0 auto;
        align-items: flex-start;
        text-align: start;
        margin-inline-start: calc(44px + var(--nbd-space-3));
    }
}

/* ── B2B-specific: per-company pricing bind form ─────────── */
.spbwc-b2b-bind {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--nbd-space-3);
    padding: var(--nbd-space-4);
    background: var(--nbd-st-bg-soft);
    border: 1px solid var(--nbd-st-border-light);
    border-radius: var(--nbd-radius-md);
    margin-top: var(--nbd-space-3);
}
.spbwc-b2b-bind label { display: flex; flex-direction: column; gap: var(--nbd-space-1); font-size: var(--text-sm); color: var(--nbd-st-text-soft); font-weight: var(--font-semibold); }

/* Tier cards grid (B2B Pricing) reuses .spbwc-list-grid + .spbwc-block. */
.spbwc-tier-discount {
    font-size: var(--text-4xl);
    font-weight: var(--font-bold);
    color: var(--st-brand);
    line-height: 1;
}

/* B2B Pricing — tier ladder rows. */
.spbwc-block__head .js-spbwc-add-tier { margin-right: auto; }
.spbwc-tier-row.is-new { background: var(--nbd-st-bg-soft); }
.spbwc-tier-row.is-new .spbwc-input { border-style: dashed; }

/* Square icon button used to drop an unsaved tier row. */
.spbwc-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--nbd-st-border-light);
    border-radius: var(--nbd-radius-md);
    background: var(--nbd-st-bg);
    color: var(--nbd-st-text-mute);
    cursor: pointer;
    transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.spbwc-icon-btn:hover {
    color: var(--nbd-color-danger);
    border-color: var(--nbd-color-danger);
    background: var(--st-pill-danger-bg);
}
.spbwc-icon-btn .dashicons { font-size: 18px; width: 18px; height: 18px; line-height: 1; }
