/* Bot Access (/bot-access) — js/pages/bot-access.js.
   Self-contained: every rule is .ba-*, on the chrome.css --color-* tokens. */

.ba-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ba-project { font-weight: 600; color: var(--color-text); white-space: nowrap; }

.ba-muted { color: var(--color-text-secondary); }
.ba-empty { color: var(--color-text-secondary); text-align: center; padding: 16px 8px; }
.ba-nowrap { white-space: nowrap; }
.ba-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ba-refused { color: #c53030; font-weight: 600; }
.ba-sub { display: block; font-size: 0.75rem; }

/* ── Tiles ── */

.ba-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.ba-tile {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 14px 16px;
}

.ba-tile-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.ba-tile-label {
    margin-top: 4px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
}

.ba-tile-foot {
    margin-top: 2px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

/* ── Cards ── */

.ba-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    min-width: 0;
}

.ba-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ba-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 10px;
}

.ba-card-sub {
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-left: 4px;
}

/* ── Daily calls chart ── */

.ba-chart { position: relative; }

.ba-chart-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 220px;
}

.ba-bar-ok { fill: var(--color-primary); }
.ba-bar-refused { fill: #dc2626; }
.ba-hit { fill: transparent; cursor: default; }
.ba-hit:hover { fill: rgba(var(--color-primary-rgb), 0.06); }
.ba-grid { stroke: var(--color-border); stroke-width: 1; }
.ba-axis { font-size: 10px; fill: var(--color-text-secondary); }

.ba-tip {
    position: absolute;
    transform: translate(-50%, -100%);
    background: var(--color-text);
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2;
}

.ba-legend {
    display: flex;
    gap: 14px;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.ba-legend span { display: inline-flex; align-items: center; gap: 5px; }

.ba-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.ba-swatch-ok { background: var(--color-primary); }
.ba-swatch-refused { background: #dc2626; }

/* ── Tables ── */

.ba-scroll { overflow-x: auto; }

.ba-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.ba-table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.ba-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--color-bg-secondary);
    vertical-align: middle;
}

.ba-table tr:last-child td { border-bottom: 0; }

/* Wide enough that the columns keep their shape; the card scrolls sideways
   on a phone instead of crushing the name column. */
.ba-bots { min-width: 1040px; }
.ba-bots td { vertical-align: top; }

.ba-name { display: block; font-weight: 600; color: var(--color-text); }

/* Inline share bar behind the call count. */
.ba-bar-cell { position: relative; min-width: 110px; }
.ba-inline-bar {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: 18px;
    max-width: calc(100% - 16px);
    background: rgba(var(--color-primary-rgb), 0.12);
    border-radius: 3px;
}
.ba-bar-val { position: relative; }

.ba-key {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.ba-key + .ba-key { margin-top: 4px; }

.ba-key code,
.ba-call code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    background: var(--color-bg-secondary);
    border-radius: 4px;
    padding: 1px 5px;
}

.ba-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.ba-actions .btn { white-space: nowrap; }

.ba-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 0.75rem;
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: underline;
}

.ba-link-danger { color: #c53030; }

.ba-foot { font-size: 0.8125rem; max-width: 760px; }

/* ── Dialogs ── */

.ba-dialog {
    width: min(520px, 92vw);
    /* main.css zeroes every margin, which un-centres a modal dialog. */
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

.ba-form { padding: 20px 22px; }

.ba-dialog-title {
    font-size: 1.0625rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--color-text);
}

.ba-hint { font-size: 0.75rem; margin-top: 4px; }

.ba-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.875rem;
    padding: 3px 0;
    cursor: pointer;
}

.ba-check input { flex: none; margin-top: 3px; accent-color: var(--color-primary); }

.ba-boards {
    max-height: 190px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 10px;
}

/* Select all stays put while the boards scroll under it. */
.ba-check-all {
    position: sticky;
    top: -6px;
    margin: -6px -10px 4px;
    padding: 8px 10px 6px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    z-index: 1;
}

.ba-rate { max-width: 120px; }

.ba-error { color: #c53030; font-size: 0.8125rem; margin-bottom: 8px; }

.ba-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.ba-warn {
    background: #feebc8;
    color: #7b341e;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8125rem;
    margin-bottom: 12px;
}

.ba-keyrow { display: flex; gap: 8px; margin-bottom: 14px; }

.ba-keybox {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}

.ba-code {
    background: var(--color-bg-secondary);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre;
    margin-top: 4px;
}

/* ── Activity drawer ── */

.ba-drawer .card-title { margin: 0; }
/* The phone stylesheet stretches buttons; this one stays a button. */
.ba-drawer .card-header .btn { flex: none; width: auto; }
.ba-drawer-note { font-size: 0.8125rem; margin: 0 0 4px; }

.ba-range {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

.ba-range label { display: inline-flex; align-items: center; gap: 6px; }

.ba-presets { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-right: 4px; }

.ba-preset-btn {
    padding: 5px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-secondary);
    font: inherit;
    font-size: 0.8125rem;
    color: var(--color-text);
    cursor: pointer;
}

.ba-preset-btn:hover { background: var(--color-bg); }
.ba-preset-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.ba-range input[type="date"] {
    font: inherit;
    font-size: 0.8125rem;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 5px 8px;
}

.ba-range input[type="date"]:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.ba-stats { margin-bottom: 8px; }

.ba-stats > div {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8125rem;
}

.ba-stats span {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.ba-section {
    font-size: 0.875rem;
    font-weight: 700;
    margin: 18px 0 6px;
    color: var(--color-text);
}

.ba-day {
    font-size: 0.8125rem;
    font-weight: 700;
    margin: 16px 0 4px;
    color: var(--color-text);
}

.ba-day span { font-weight: 400; color: var(--color-text-secondary); margin-left: 6px; }

.ba-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ba-feed-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-bg-secondary);
    font-size: 0.8125rem;
}

.ba-feed-item:last-child { border-bottom: 0; }

.ba-feed-time {
    flex: 0 0 84px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ba-call { min-width: 0; overflow-wrap: anywhere; }

.ba-chip {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.ba-chip-denied { margin-left: auto; flex-shrink: 0; background: #fed7d7; color: #9b2c2c; }

@media (max-width: 900px) {
    .ba-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ba-actions { flex-wrap: wrap; justify-content: flex-start; }
}

@media (max-width: 520px) {
    .ba-keyrow { flex-direction: column; }
    .ba-feed-time { flex-basis: 72px; }
}
