/*
 * Admin redesign (2026-11-22): the parts that the 11-12 design adds to the
 * admin shell. Colours come from the admin tokens only (css/admin-shell.css).
 * Spacing uses the 4pt scale. Every class here starts with "rd-".
 */

/* Segmented filter: a row of choices, one pressed. Buttons with aria-pressed. */
.rd-seg {
    display: inline-flex;
    max-width: 100%;
    padding: 2px;
    overflow-x: auto;
    border-radius: 8px;
    background: var(--color-surface-2);
    scrollbar-width: none;
}
.rd-seg::-webkit-scrollbar { display: none; }
.rd-seg > button {
    flex: none;
    padding: 6px 12px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--color-text-2);
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
}
.rd-seg > button[aria-pressed="true"] {
    background: var(--color-surface-bg);
    color: var(--color-text-1);
    font-weight: 600;
}
.rd-seg > button:disabled { opacity: 0.45; cursor: default; }
.rd-seg .rd-count { margin-left: 4px; color: var(--color-text-3); font-weight: 400; }

/* A list with the open item beside it. Stacks below 1100px. */
.rd-split {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.rd-panel {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
    overflow: hidden;
}
.rd-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}
.rd-panel-head h3 { margin: 0 auto 0 0; font-size: 16px; font-weight: 600; }
.rd-panel-body { padding: 16px; }
.rd-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Label and value pairs. */
.rd-kv {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 8px 12px;
    margin: 0;
}
.rd-kv dt { color: var(--color-text-2); }
.rd-kv dd { margin: 0; overflow-wrap: anywhere; }

/* Needs attention: one line for each thing that waits; only the non-zero ones. */
.rd-att > a,
.rd-att > button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.rd-att > :last-child { border-bottom: 0; }
.rd-att strong { font-weight: 600; }
.rd-att .rd-go { margin-left: auto; color: var(--color-text-2); white-space: nowrap; }

/* A state with one action (the Billing block of a client). No form fields. */
.rd-bill { display: grid; gap: 8px; }
.rd-bill-state { font-size: 16px; font-weight: 600; }
.rd-bill-state[data-tone="danger"] { color: var(--status-danger-text); }
.rd-bill-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* What stops an action, with its fix. Only failed items show. */
.rd-need {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--status-danger-soft);
    color: var(--status-danger-text);
}
.rd-need > span { flex: 1; color: var(--color-text-1); }

/* The lines of a confirmation: who and how much. */
.rd-lines { width: 100%; border-collapse: collapse; }
.rd-lines td { padding: 8px 0; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.rd-lines tr:last-child td { border-bottom: 0; }
.rd-lines td:last-child { text-align: right; white-space: nowrap; }
.rd-sub { color: var(--color-text-2); font-size: 12px; }

/* A page of one item inside a view: breadcrumb above, Save bar below. */
.rd-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    color: var(--color-text-2);
    font-size: 13px;
}
.rd-crumb a, .rd-crumb button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-decoration: none; padding: 0; }
.rd-crumb a:hover, .rd-crumb button:hover { color: var(--color-text-1); }
.rd-savebar {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-bg);
}
.rd-savebar .rd-spacer { flex: 1; }

/* A switch (on / off). An <input type="checkbox" class="rd-switch">. */
input.rd-switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 36px;
    height: 20px;
    margin: 0;
    border-radius: 10px;
    background: var(--color-surface-2);
    vertical-align: middle;
    cursor: pointer;
}
input.rd-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-text-2);
}
input.rd-switch:checked { background: var(--color-action-primary); }
input.rd-switch:checked::after { left: 19px; background: var(--color-action-primary-text); }
input.rd-switch:disabled { opacity: 0.45; cursor: default; }

/* Search and date boxes of a view: the field look of the shell (they had the browser's). */
.tab-content input[type="search"],
.tab-content input[type="date"],
.tab-content input.filter-input {
    min-height: 34px;
    padding: 4px 12px;
    border: 1px solid var(--color-control-border);
    border-radius: 8px;
    background: var(--color-field);
    color: var(--color-text-1);
    font: inherit;
    font-size: 13px;
}
.tab-content input[type="search"]::placeholder,
.tab-content input.filter-input::placeholder { color: var(--color-text-3); }

/* Smaller screens. */
@media (max-width: 1100px) {
    .rd-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
    .rd-kv { grid-template-columns: 110px minmax(0, 1fr); }
}

/* ---- Chat (2026-11-23): the Chat area and the Overview threads (admin-chat.js). ---- */

/* Two columns; one when the second is hidden, and below 1100px. */
.rd-chat-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.rd-chat-grid:has(> .section[hidden]) { grid-template-columns: minmax(0, 1fr); }
.rd-chat-grid > .section,
.rd-chat-side > .section { margin: 0; }
.rd-chat-side { display: grid; gap: 16px; min-width: 0; }

/* A channel, a person or a thread: one row, one link into Chat. */
.rd-chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    color: inherit;
    text-decoration: none;
}
.rd-chat-list > :last-child { border-bottom: 0; }
a.rd-chat-row:hover { background: var(--color-row-hover); }
.rd-chat-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-surface-2);
    color: var(--color-text-2);
}
.rd-chat-icon.is-person { border-radius: 50%; color: var(--color-text-1); font-size: 12px; font-weight: 600; }
.rd-chat-body { display: block; flex: 1; min-width: 0; }
.rd-chat-name,
.rd-chat-last { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-chat-name { color: var(--color-text-2); }
.rd-chat-row.is-unread .rd-chat-name,
.rd-chat-row.is-thread .rd-chat-name { color: var(--color-text-1); }
.rd-chat-row.is-unread .rd-chat-name { font-weight: 600; }
.rd-chat-last { color: var(--color-text-2); font-size: 13px; }
.rd-chat-time { flex: none; color: var(--color-text-2); font-size: 12px; }
.rd-chat-count {
    flex: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--status-indigo);
    color: var(--color-surface-bg);
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
}
.rd-chat-count.is-mention { background: var(--color-action-primary); color: var(--color-action-primary-text); }
.rd-chat-replies { display: inline-flex; flex: none; align-items: center; gap: 4px; color: var(--color-text-2); font-size: 13px; }
.rd-chat-replies svg { color: var(--status-indigo); }
.rd-chat-group { margin: 0; padding: 12px 16px 4px; color: var(--color-text-2); font-size: 12px; font-weight: 400; }

/* Needs attention with Chat on: the row link, then its thread control. */
.rd-att[data-chat-threads] { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.rd-att[data-chat-threads] > a:nth-last-child(2) { border-bottom: 0; }
.rd-chat-thr-cell {
    display: flex;
    align-items: center;
    padding: 0 16px 0 0;
    border-bottom: 1px solid var(--color-border);
}
.rd-chat-thr {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: none;
    color: var(--color-text-1);
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}
.rd-chat-thr svg { color: var(--status-indigo); }
.rd-chat-thr.is-new { color: var(--color-text-2); }
.rd-chat-thr:hover { background: var(--color-row-hover); }
.rd-chat-thr[aria-disabled="true"] { opacity: 0.45; cursor: default; }

/* Tables of the Chat views. */
.rd-chat-table { width: 100%; }
.rd-chat-table .rd-chat-num { text-align: right; font-variant-numeric: tabular-nums; }
.rd-chat-table .rd-chat-act { text-align: right; white-space: nowrap; }
.rd-chat-table tr.is-dim > td { color: var(--color-text-2); }

/* Messages that Chat shows, against the free plan limit. */
.rd-chat-stat {
    display: grid;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface-1);
}
.rd-chat-stat strong { font-size: 24px; font-weight: 600; line-height: 1.2; }
.rd-chat-stat span { color: var(--color-text-2); font-size: 13px; }
.rd-chat-bar { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--color-surface-2); overflow: hidden; }
.rd-chat-bar > i { display: block; width: 0; height: 100%; background: var(--status-green); }
.rd-chat-bar[data-tone="orange"] > i { background: var(--status-orange); }
.rd-chat-bar[data-tone="red"] > i { background: var(--status-red); }

@media (max-width: 1100px) {
    .rd-chat-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
    .rd-chat-time { display: none; }
    .rd-chat-thr { justify-content: center; min-width: 44px; min-height: 44px; }
    #chat-tab .btn,
    #chat-tab .panel-age-retry,
    #overviewChat .btn { min-height: 44px; }
}
