/* =================================================================
   WF Portal - the shared components (portal-look-and-feel.md 3.11 - 3.14)
   -----------------------------------------------------------------
   The new shared pieces every page can use: the pressable chip, the
   status pill, the code chip and count, the segmented control, icon
   tiles and tones, deltas, empty states, skeletons, choice cards, the
   settings layout, and the charts (HTML columns, bars, stacks,
   meters, rings). Every class here is wf- prefixed and owned by this
   file alone (Tests/ConversationBuilderCssOwnershipTests).

   TOKENS ONLY, the whole file (Tests/ShellTokensOnlyTests): no hex,
   no rgb() / hsl(), no colour keyword - every colour reads a --wf-*,
   --theme-* or --conv-* token, so a tenant theme (dark, grey, any
   radius) re-skins all of it. black / white appear only as a
   color-mix() target; the one content exception is .wf-qr (a scanner
   needs black on white in every theme).
   ================================================================= */

/* ---- The pressable chip (filters with counts, the composer's starts) ---- */
.wf-chip-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 13px;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-pill);
    background: var(--wf-card);
    color: var(--theme-text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--wf-motion), background var(--wf-motion);
}
.wf-chip-toggle > .bi { color: var(--wf-primary-ink); }
.wf-chip-toggle:hover { border-color: var(--wf-primary-ink); background: var(--wf-primary-soft); }
/* On = pressed (a toggle) OR checked (one of a radio group - role="radio" carries aria-checked, never aria-pressed). */
.wf-chip-toggle[aria-pressed="true"],
.wf-chip-toggle[aria-checked="true"] {
    border-color: color-mix(in srgb, var(--wf-primary-ink) 55%, transparent);
    background: var(--wf-primary-soft);
    color: var(--theme-text-emphasis);
}
.wf-chip-toggle:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; }
.wf-chip-toggle:disabled { opacity: .55; cursor: not-allowed; }
/* Touch: a finger needs a 44px target - the chip grows, its look does not change. */
@media (pointer: coarse) {
    .wf-chip-toggle { min-height: 44px; }
}
.wf-chip-count { color: var(--theme-text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- The status pill: a dot and a WORD, never colour alone ---- */
.wf-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 9px 0 7px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.wf-status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.wf-status-pill.is-live { background: var(--wf-success-soft); color: var(--wf-success-ink); }
.wf-status-pill.is-ahead { background: var(--wf-warning-soft); color: var(--wf-warning-ink); }
.wf-status-pill.is-fix { background: var(--wf-danger-soft); color: var(--wf-danger-ink); }
.wf-status-pill.is-draft { background: var(--wf-neutral-soft); color: var(--theme-text-secondary); }
.wf-status-pill.is-quiet::before,
.wf-status-pill.is-paused::before,
.wf-status-pill.is-ended::before { content: none; }
.wf-status-pill.is-ended { color: var(--theme-text-muted); text-decoration: line-through; }

/* ---- The code chip and the neutral count ---- */
.wf-codechip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--wf-radius-xs);
    background: var(--wf-inset);
    color: var(--theme-text-secondary);
    font: 600 11.5px var(--theme-font-mono);
    letter-spacing: .02em;
}
.wf-count {
    display: inline-block;
    min-width: 20px;
    padding: 0 7px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---- The segmented control (Today | 7 days | 30 days) ---- */
.wf-seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-pill);
    background: var(--wf-inset);
}
.wf-seg > button {
    height: 28px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--wf-radius-pill);
    background: transparent;
    color: var(--theme-text-secondary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.wf-seg > button:hover { color: var(--theme-text-emphasis); }
/* The chosen segment: pressed, or checked when the control is a radio group (role="radio" - the Operator's single choices). */
.wf-seg > button[aria-pressed="true"],
.wf-seg > button[aria-checked="true"] { background: var(--wf-card); color: var(--theme-text-emphasis); box-shadow: var(--wf-elev-1); }
.wf-seg > button:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 1px; }

/* ---- Icon tiles and their tones (a family hue ONLY on a family) ---- */
.wf-tile-ic {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: var(--wf-radius-tile);
    background: var(--wf-primary-soft);
    color: var(--wf-primary-ink);
    font-size: 16px;
}
.wf-tile-ic.is-lg { width: 44px; height: 44px; font-size: 20px; }
.wf-tone-primary { background: var(--wf-primary-soft); color: var(--wf-primary-ink); }
.wf-tone-neutral { background: var(--wf-neutral-soft); color: var(--theme-text-secondary); }
.wf-tone-success { background: var(--wf-success-soft); color: var(--wf-success-ink); }
.wf-tone-warning { background: var(--wf-warning-soft); color: var(--wf-warning-ink); }
.wf-tone-new { background: var(--wf-accent-soft); color: var(--wf-accent-ink); }
.wf-fam-tile-ask { background: var(--conv-ask-soft); color: var(--conv-ask-ink); }
.wf-fam-tile-say { background: var(--conv-say-soft); color: var(--conv-say-ink); }
.wf-fam-tile-act { background: var(--conv-act-soft); color: var(--conv-act-ink); }
.wf-fam-tile-flow { background: var(--conv-flow-soft); color: var(--conv-flow-ink); }

/* ---- Deltas: up is good news; DOWN IS NEVER RED (muted, with its arrow) ---- */
.wf-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.wf-delta.is-up { color: var(--wf-success-ink); }
.wf-delta.is-down,
.wf-delta.is-flat { color: var(--theme-text-muted); }

/* ---- The KPI tile: ONE divided card, never a stack of boxes (portal-look-and-feel 3.9, 3.18) ----
   <div class="card wf-kpis"> + <KpiTile> per figure (Components/Common/KpiTile). The dividers are a 1px
   shadow on each tile's left and top; the card clips the ones on its outer edge, so a row that wraps on a
   narrow page gets its own top hairline and no tile ever carries a stray border. A tile that is a door
   (Href) lifts its fill on hover. */
.wf-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
    overflow: hidden;
}
.wf-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 18px 20px;
    box-shadow: -1px 0 0 var(--wf-line), 0 -1px 0 var(--wf-line);
    color: inherit;
    text-decoration: none;
    transition: background var(--wf-motion);
}
a.wf-kpi:hover { background: var(--wf-card-hover); text-decoration: none; }
a.wf-kpi:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; }
/* A pressable tile (OnClick - a filter, the Answer Center's status tiles): a button that looks like its neighbours,
   lifts its fill on hover, and while it IS the filter wears the primary soft fill, a primary-ink bar under it and a
   funnel by its label - aria-pressed carries the state, never colour alone. */
button.wf-kpi {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
button.wf-kpi:hover { background: var(--wf-card-hover); }
button.wf-kpi:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; }
button.wf-kpi[aria-pressed="true"] {
    background: var(--wf-primary-soft);
    box-shadow: -1px 0 0 var(--wf-line), 0 -1px 0 var(--wf-line), inset 0 -3px 0 var(--wf-primary-ink);
}
.wf-kpi-label-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wf-kpi-pressed { margin-left: auto; color: var(--wf-primary-ink); font-size: 11px; }
.wf-kpi.is-hero { grid-column: span 2; }
.wf-kpi-label { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--theme-text-secondary); font-size: 13px; font-weight: 600; }
.wf-kpi-label > .bi { flex: none; color: var(--wf-primary-ink); }
.wf-kpi-value {
    margin-top: 4px;
    overflow: hidden;
    color: var(--theme-text-emphasis);
    font-size: var(--wf-figure-md);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.wf-kpi.is-hero .wf-kpi-value { font-size: var(--wf-figure); }
.wf-kpi-value.is-words { font-size: var(--wf-figure-sm); letter-spacing: -0.01em; }
.wf-kpi-value.is-muted { color: var(--theme-text-muted); }
.wf-kpi-sub { color: var(--theme-text-muted); font-size: 12.5px; line-height: 1.4; }
.wf-kpi-extra { margin-top: 8px; }

/* ---- Empty states: an invitation, never a shrug ---- */
.wf-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px 24px;
    text-align: center;
}
.wf-empty-art {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    background: var(--wf-brand-wash), var(--wf-card);
    color: var(--wf-primary-ink);
    font-size: 26px;
}
.wf-empty-art svg { width: 44px; height: 44px; }
.wf-empty-title { margin: 0; color: var(--theme-text-emphasis); font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.01em; }
.wf-empty-text { max-width: 46ch; margin: 0 0 10px; color: var(--theme-text-secondary); font-size: 13.5px; }
.wf-empty-action { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.wf-empty.is-compact { padding: 20px 16px; }
.wf-empty.is-compact .wf-empty-art { width: 48px; height: 48px; font-size: 20px; }
.wf-empty.is-nomatch .wf-empty-art { background: var(--wf-card); color: var(--theme-text-muted); }

/* ---- Skeletons: the shape of what is coming ---- */
.wf-skel { position: relative; overflow: hidden; min-height: 12px; border-radius: var(--wf-radius-md); background: var(--wf-inset); }
.wf-skel::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--wf-card) 60%, transparent), transparent);
    animation: wf-skel-shimmer 1.4s infinite;
}
.wf-skel.is-line { height: 12px; border-radius: var(--wf-radius-xs); }
@keyframes wf-skel-shimmer { to { transform: translateX(100%); } }
/* A refetch keeps the old numbers on screen, dimmed, until the new ones land (no flash, no jump). */
.wf-refreshing { opacity: .6; transition: opacity var(--wf-motion); }

/* ---- Choice cards: 2-5 options that each need a sentence ---- */
.wf-choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 10px; }
.wf-choice {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 12px 14px 12px 14px;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-md);
    background: var(--wf-card);
    color: var(--theme-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--wf-motion), background var(--wf-motion), box-shadow var(--wf-motion);
}
.wf-choice:hover { border-color: var(--wf-primary-ink); }
.wf-choice:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; }
.wf-choice[aria-checked="true"],
.wf-choice.is-checked {
    border-color: var(--wf-primary-ink);
    background: var(--wf-primary-soft);
    box-shadow: 0 0 0 1px var(--wf-primary-ink);
}
.wf-choice-title { display: flex; align-items: center; gap: 8px; padding-right: 26px; color: var(--theme-text-emphasis); font-size: 14px; font-weight: 600; }
.wf-choice-title > .bi { color: var(--wf-primary-ink); }
.wf-choice-text { color: var(--theme-text-secondary); font-size: 12.5px; line-height: 1.45; }
.wf-choice-check {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    font-size: 12px;
}
.wf-choice[aria-checked="true"] .wf-choice-check,
.wf-choice.is-checked .wf-choice-check { display: grid; }

/* ---- The settings layout: a title + one sentence of why, then the fields ---- */
.wf-form-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 16px 32px;
    padding: 24px 0;
    border-top: 1px solid var(--wf-line);
}
.wf-form-section:first-child { border-top: 0; padding-top: 0; }
.wf-form-section-title { margin: 0; color: var(--theme-text-emphasis); font-size: var(--wf-text-h3); font-weight: 650; }
.wf-form-section-text { margin: 4px 0 0; color: var(--theme-text-secondary); font-size: 13px; }
.wf-form-section-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 767.98px) {
    .wf-form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

/* =================================================================
   CHARTS (Components/Common/Charts) - one hue per chart (--wf-data);
   the window you picked is bright, context is quiet; today is a
   column, "so far"; down is never red. Geometry: ChartGeometry.cs.
   ================================================================= */
.wf-chart { position: relative; min-width: 0; }
.wf-chart-plot { position: relative; border-radius: var(--wf-radius-xs); }
/* The top hairline's label sits ABOVE the plot - leave it room so it never meets the figure over the chart. */
.wf-chart-plot.has-grid { margin-top: 1.25rem; }
.wf-chart-plot:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 4px; }
.wf-chart-toggle { margin-top: 8px; }
.wf-chart-table { margin: 0; font-size: 13px; }
.wf-chart-table td:last-child,
.wf-chart-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* -- HTML columns: crisp at any width, no measuring, the radius follows the tenant -- */
.wf-cols { position: relative; display: flex; align-items: flex-end; gap: 2px; height: var(--wf-cols-h, 46px); }
.wf-cols-col { position: relative; display: flex; flex: 1; align-items: flex-end; height: 100%; min-width: 0; }
.wf-cols-bar {
    display: block;
    width: 100%;
    max-width: 22px;
    margin: 0 auto;
    border-radius: min(4px, var(--theme-radius-button)) min(4px, var(--theme-radius-button)) 0 0;
    background: var(--wf-data-quiet);
    transition: background var(--wf-motion);
}
.wf-cols-col.is-on > .wf-cols-bar { background: var(--wf-data); }
.wf-cols-col.is-zero > .wf-cols-bar { height: 2px !important; background: var(--wf-data-grid); }
.wf-cols.is-overlay .wf-cols-col > .wf-cols-bar { background: var(--wf-data-quiet); }
.wf-cols-overlay {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 100%;
    max-width: 22px;
    border-radius: min(4px, var(--theme-radius-button)) min(4px, var(--theme-radius-button)) 0 0;
    background: var(--wf-data);
    transform: translateX(-50%);
    pointer-events: none;
}
.wf-cols-col:hover > .wf-cols-bar,
.wf-cols-col.is-cursor > .wf-cols-bar { filter: brightness(1.12) saturate(1.1); }
.wf-cols-col.is-cursor > .wf-cols-bar { box-shadow: 0 0 0 2px var(--wf-card), 0 0 0 4px var(--wf-primary-ink); }
.wf-cols-tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 5;
    padding: 6px 9px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-sm);
    background: var(--wf-card);
    box-shadow: var(--wf-elev-2);
    color: var(--theme-text-secondary);
    font-size: 12px;
    white-space: nowrap;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 80ms;
}
.wf-cols-tip > b { display: block; color: var(--theme-text-emphasis); font-size: 13px; font-weight: 650; }
.wf-cols-col:hover > .wf-cols-tip,
.wf-cols-col.is-cursor > .wf-cols-tip { opacity: 1; }
.wf-cols-col.is-start > .wf-cols-tip { left: 0; transform: none; }
.wf-cols-col.is-end > .wf-cols-tip { right: 0; left: auto; transform: none; }
.wf-cols-grid { position: absolute; inset: 0; pointer-events: none; }
.wf-cols-grid > span { position: absolute; left: 0; right: 0; border-top: 1px solid var(--wf-data-grid); }
.wf-cols-grid em {
    position: absolute;
    left: 0;
    transform: translateY(-120%);
    color: var(--theme-text-muted);
    font-size: 11px;
    font-style: normal;
    font-variant-numeric: tabular-nums;
}
.wf-cols-note {
    position: absolute;
    z-index: 2;
    padding: 1px 6px;
    border-radius: var(--wf-radius-xs);
    background: var(--wf-card);
    color: var(--theme-text-secondary);
    font-size: 11.5px;
    white-space: nowrap;
    transform: translate(-50%, -6px);
    pointer-events: none;
}
.wf-cols-note > b { color: var(--theme-text-emphasis); font-weight: 650; }
/* Near an edge the note hangs inward from its column instead of running off the chart. */
.wf-cols-note.is-start { transform: translate(0, -6px); }
.wf-cols-note.is-end { transform: translate(-100%, -6px); }
.wf-cols-axis {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--theme-text-muted);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

/* -- Horizontal bars (channels, launch codes by their answers) -- */
.wf-hbars { display: flex; flex-direction: column; }
.wf-hbar-row {
    display: grid;
    grid-template-columns: minmax(6rem, 10rem) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 7px 0;
    font-size: 13px;
}
.wf-hbar-label { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; color: var(--theme-text); white-space: nowrap; text-overflow: ellipsis; }
.wf-hbar-label > .bi { color: var(--theme-text-muted); }
.wf-hbar-track { display: block; min-width: 0; }
.wf-hbar-fill { display: block; height: 10px; border-radius: 0 var(--wf-radius-xs) var(--wf-radius-xs) 0; background: var(--wf-data); }
.wf-hbar-value { color: var(--theme-text-emphasis); font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.wf-hbar-detail { margin-left: 4px; color: var(--theme-text-muted); font-weight: 500; }

/* -- The stacked bar, always with its legend (labels and counts) -- */
.wf-stackbar { display: flex; gap: 2px; height: 12px; overflow: hidden; border-radius: var(--wf-radius-pill); background: var(--wf-inset); }
.wf-stackbar-seg { display: block; min-width: 2px; height: 100%; }
.wf-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--theme-text-secondary); font-size: 12.5px; }
.wf-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.wf-legend-item > b { color: var(--theme-text-emphasis); font-weight: 650; font-variant-numeric: tabular-nums; }
.wf-legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: var(--wf-radius-xs); }
.wf-stackbar-seg.is-data, .wf-legend-swatch.is-data { background: var(--wf-data); }
.wf-stackbar-seg.is-quiet, .wf-legend-swatch.is-quiet { background: var(--wf-data-quiet); }
.wf-stackbar-seg.is-success, .wf-legend-swatch.is-success { background: var(--theme-success); }
.wf-stackbar-seg.is-warning, .wf-legend-swatch.is-warning { background: var(--theme-warning); }
.wf-stackbar-seg.is-empty, .wf-legend-swatch.is-empty { background: var(--wf-line-strong); }

/* -- The meter (finished share) -- */
.wf-meter { display: block; height: 6px; overflow: hidden; border-radius: var(--wf-radius-pill); background: var(--wf-success-soft); }
.wf-meter-fill { display: block; height: 100%; border-radius: inherit; background: var(--theme-success); }
.wf-meter.is-data { background: var(--wf-data-soft); }
.wf-meter.is-data > .wf-meter-fill { background: var(--wf-data); }

/* -- The progress ring (getting started 0/4) -- */
.wf-ring { display: block; flex: none; }
.wf-ring-track { fill: none; stroke: var(--wf-inset); stroke-width: 6; }
.wf-ring-arc { fill: none; stroke: var(--wf-data); stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray var(--wf-motion-panel); }
.wf-ring-label { fill: var(--theme-text-emphasis); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* -- The documented exception: a QR code is content, black on white in every theme -- */
.wf-qr { display: inline-block; padding: 8px; border-radius: var(--wf-radius-sm); background: white; color: black; }

@media (prefers-reduced-motion: reduce) {
    .wf-skel::after { animation: none; }
    .wf-cols-bar, .wf-cols-tip, .wf-ring-arc, .wf-chip-toggle, .wf-choice { transition: none; }
}
