/*
 * Cash Bots filter / selection / bulk-action
 * controls. Presentation-only: paired with views/bots.js, which emits the
 * class hooks below. No logic lives here. Reuses the admin design-token
 * layer (design-tokens.css) so the controls stay theme-consistent with the
 * rest of the kit (.card, .data-table, .btn, .stat).
 *
 * Scoped under .main so it cannot leak outside the admin content column,
 * matching components.css / admin.css convention.
 */

/* ── Filter toolbar ──────────────────────────────────────────────────────
   Search + segmented status filter + right-aligned filtered count, all on
   one wrapping row. */
.main .bots-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.main .bots-toolbar__search {
    flex: 1 1 200px;
    max-width: 260px;
}
.main .bots-toolbar__total {
    margin-left: auto;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Segmented status control ────────────────────────────────────────────
   iOS-style pill group: raised "thumb" for the active segment on a sunken
   track. Each segment carries a count badge (gold when active). */
.main .bots-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--surface-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.main .bots-seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 11px;
    border: 0;
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.main .bots-seg:hover:not(.is-active) {
    background: var(--surface-hover);
    color: var(--color-text);
}
.main .bots-seg.is-active {
    background: var(--surface-raised);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}
.main .bots-seg:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
}
.main .bots-seg__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.main .bots-seg:hover:not(.is-active) .bots-seg__count {
    background: var(--surface-raised);
}
.main .bots-seg.is-active .bots-seg__count {
    background: var(--color-accent);
    color: #1A1206;             /* warm near-black on gold for AA contrast */
}

/* ── Selection toolbar ───────────────────────────────────────────────────
   "Select all filtered" checkbox + compact "Select first N" group, divided
   from the filter row by a hairline. */
.main .bots-selectbar {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex-wrap: wrap;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--hairline);
}
.main .bots-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
}
.main .bots-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--color-accent);
    cursor: pointer;
}
.main .bots-check input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}
.main .bots-selectbar__sep {
    width: 1px;
    align-self: stretch;
    background: var(--hairline);
}
.main .bots-firstn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}
.main .bots-firstn__input {
    width: 76px;
    text-align: center;
}
.main .bots-selectbar .btn {
    padding: 7px 12px;
    font-size: var(--text-xs);
}

/* ── Bulk action bar ─────────────────────────────────────────────────────
   Appears (rendered) only when ≥1 bot is selected. A prominent raised band
   with a gold left-accent so it reads as the active context without being
   loud. Set Cash = primary (accent); MTT/All = secondary; Clear = ghost. */
.main .bots-bulkbar {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex-wrap: wrap;
    margin-top: var(--space-md);
    padding: 12px var(--space-base);
    background: var(--surface-raised);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    animation: bots-bulkbar-in 180ms ease;
}
@keyframes bots-bulkbar-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .main .bots-bulkbar { animation: none; }
}
.main .bots-bulkbar__count {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}
.main .bots-bulkbar__count::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(245, 200, 66, 0.25);
}
.main .bots-bulkbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-left: auto;
}
.main .bots-bulkbar__actions .btn {
    padding: 7px 12px;
    font-size: var(--text-xs);
}
/* Ghost "Clear selection" — quiet text button, no fill/border at rest. */
.main .bots-bulkbar__clear {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--color-text-muted);
}
.main .bots-bulkbar__clear:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--color-border);
    color: var(--color-text);
}

/* ── Selection column in the bots data-table ─────────────────────────────
   Tidy fixed-width leading checkbox column + accent checkboxes + a soft
   tint on selected rows. */
.main .bots-grid th:first-child,
.main .bots-grid td:first-child {
    width: 40px;
    padding-left: var(--space-md);
    padding-right: 0;
    text-align: center;
}
.main .bots-grid td:first-child input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--color-accent);
    cursor: pointer;
    vertical-align: middle;
}
.main .bots-grid tbody tr.is-selected {
    background: rgba(245, 200, 66, 0.07);
}
.main .bots-grid tbody tr.is-selected:hover {
    background: rgba(245, 200, 66, 0.12);
}

/* ════════════════════════════════════════════════════════════════════════
   Two clear dimensions: STATUS (live deployment) vs SCOPE
   (allocation). Functional baseline below; fine visual polish (badge palette,
   section spacing, segmented control) is a separate VS Code pass.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Filter axes ─────────────────────────────────────────────────────────
   Each axis (Status / Scope) gets a small leading label so the two
   segmented controls never read as one ambiguous filter row. */
.main .bots-filter-axis {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.main .bots-filter-axis--scope {
    margin-top: var(--space-md);
}
.main .bots-filter-axis__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* ── Per-bot scope badge (list "Scope" column) ───────────────────────────
   Colour-coded by data-scope so the reservation reads at a glance, distinct
   from the status chip. Soft tinted fill + matching text, theme-safe. */
.main .bots-scope-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
}
.main .bots-scope-badge[data-scope="all"] {
    background: var(--surface-sunken);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}
.main .bots-scope-badge[data-scope="cash"] {
    background: rgba(70, 182, 126, 0.14);
    color: #2f8f5e;
    border-color: rgba(70, 182, 126, 0.32);
}
.main .bots-scope-badge[data-scope="mtt"] {
    background: rgba(124, 116, 240, 0.16);
    color: #5b54c9;
    border-color: rgba(124, 116, 240, 0.34);
}
.main .bots-scope-badge[data-scope="sng"] {
    background: rgba(239, 138, 46, 0.16);
    color: #c96f1e;
    border-color: rgba(239, 138, 46, 0.34);
}
.main .bots-scope-badge[data-scope="spg"] {
    background: rgba(56, 158, 220, 0.16);
    color: #2682b8;
    border-color: rgba(56, 158, 220, 0.34);
}

/* ── Stat card: two grouped sections (deployment vs scope) ────────────────*/
.main .bots-statgroup + .bots-statgroup {
    margin-top: var(--space-base);
    padding-top: var(--space-base);
    border-top: 1px solid var(--hairline);
}
.main .bots-statgroup__head {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}
.main .bots-statgroup__title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-text);
}
.main .bots-statgroup__hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.main .bots-statnote {
    margin: var(--space-base) 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
}
/* Scope KPI cells echo the badge accent on a thin left rule. */
.main .bots-stat--scope[data-scope="cash"] { box-shadow: inset 3px 0 0 rgba(70, 182, 126, 0.55); }
.main .bots-stat--scope[data-scope="mtt"]  { box-shadow: inset 3px 0 0 rgba(124, 116, 240, 0.6); }
.main .bots-stat--scope[data-scope="sng"]  { box-shadow: inset 3px 0 0 rgba(239, 138, 46, 0.6); }
.main .bots-stat--scope[data-scope="spg"]  { box-shadow: inset 3px 0 0 rgba(56, 158, 220, 0.6); }
.main .bots-stat--scope[data-scope="all"]  { box-shadow: inset 3px 0 0 var(--color-accent); }

/* ── Cross-link between Cash Bots ⇄ MTT Bots ──────────────────────────────
   Quiet inline link rendered inside the page intro paragraph. */
.main .bots-crosslink {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--color-accent);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.main .bots-crosslink:hover {
    color: var(--color-text);
}
.main .bots-crosslink:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
