/* Half-Life · workspace views (connections, setup, register, probes).
   Own classes are .ws-*; tokens and shared components come from theme.css (shadcn zinc). */

/* ---------- page frame ---------- */
.ws-page { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.ws-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ws-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.ws-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-title { font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; color: var(--text); }
.ws-lede { color: var(--text-2); font-size: 14px; line-height: 1.5; max-width: 72ch; }
.ws-muted { color: var(--text-2); font-size: 14px; line-height: 1.5; }
.ws-faint { color: var(--text-3); }
.ws-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ws-spacer { flex: 1 1 auto; }
.ws-ico { flex: none; }

.ws-page a:not(.btn) { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.ws-page a:not(.btn):hover { text-decoration-color: currentColor; }
.ws-page a:not(.btn):focus-visible { outline: 2px solid var(--text-3); outline-offset: 2px; border-radius: 2px; }

/* brand logos (svgl). theme.css owns .logo-light/.logo-dark; these scoped rules are a safe fallback. */
.ws-brand { display: inline-flex; align-items: center; flex: none; }
.ws-logo { display: block; flex: none; }
.ws-brand .logo-dark { display: none; }
:root[data-theme="dark"] .ws-brand .logo-light { display: none; }
:root[data-theme="dark"] .ws-brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ws-brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .ws-brand .logo-dark { display: block; }
}

/* ---------- forms ---------- */
.ws-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ws-wide { grid-column: 1 / -1; }
.ws-field { min-width: 0; }
.ws-opt { font-weight: 400; color: var(--text-3); font-size: 13px; margin-left: 4px; }
.ws-hint { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.ws-err { font-size: 13px; color: var(--danger); line-height: 1.45; }
.ws-form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.ws-field .input[type="date"] { font-family: var(--font-mono); font-size: 13px; }
/* inline "refresh" link-button inside a field hint */
.ws-inline-btn { padding: 0 4px; min-height: 0; height: auto; font-size: inherit; font-weight: 500; vertical-align: baseline; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- loading, error, empty ---------- */
.ws-skel { display: flex; flex-direction: column; gap: 8px; }
.ws-skel-row { height: 36px; border-radius: var(--radius-sm); }
.ws-list > .ws-skel { padding: 16px; }

.ws-error { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ws-list > .ws-error { border: 0; border-radius: 0; }
.ws-error > div { flex: 1 1 200px; min-width: 0; }
.ws-error-icon { color: var(--danger); display: inline-flex; }
.ws-error-title { font-size: 14px; font-weight: 600; color: var(--text); }
.ws-error .ws-muted { font-size: 13px; overflow-wrap: anywhere; }

.ws-empty { display: flex; align-items: flex-start; gap: 12px; padding: 20px 16px; }
.ws-empty p.ws-muted { font-size: 13px; max-width: 60ch; }
.ws-empty-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); flex: none; }
.ws-empty-ok .ws-empty-icon { color: var(--ok); }
.ws-empty-title { font-size: 14px; font-weight: 600; color: var(--text); }
.empty-state.ws-empty-lg .ws-empty-icon { width: 40px; height: 40px; margin-bottom: 4px; }
.empty-state.ws-empty-lg .btn { margin-top: 12px; }

/* ---------- badges + dots used for status ---------- */
.ws-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--stage-watch, var(--text-3)); }
[data-tone="ok"] > .ws-dot { background: var(--ok); }
[data-tone="needs"] > .ws-dot { background: var(--warn); }
[data-tone="error"] > .ws-dot { background: var(--danger); }
[data-tone="idle"] > .ws-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
[data-tone="off"] > .ws-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.ws-count { font-family: var(--font-mono); font-weight: 500; margin-left: 2px; }

/* ================================================================ CONNECTIONS */
.ws-conn-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.ws-conn-card { display: flex; flex-direction: column; gap: 16px; padding: 24px; min-width: 0; }
.ws-conn-top { display: flex; align-items: flex-start; gap: 12px; }
.ws-conn-top > .ws-brand { margin-top: 2px; }
.ws-conn-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ws-conn-name h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.ws-connstate { flex: none; gap: 6px; white-space: nowrap; }
.ws-connstate::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.ws-connstate[data-state="ok"]::before { background: var(--ok); }
.ws-connstate[data-state="missing"]::before { background: var(--warn); }
.ws-powers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); }
.ws-powers li { display: flex; align-items: flex-start; gap: 8px; }
.ws-powers svg { color: var(--text-3); margin-top: 3px; }
.ws-conn-extra { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.ws-noconn { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); }
.ws-noconn svg { color: var(--text-3); margin-top: 3px; }

.ws-hub-sec { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.ws-sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ws-sec-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-hub { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; min-width: 0; }
.ws-hub-body { position: relative; height: clamp(520px, calc(100vh - 240px), 760px); }
.ws-hub-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--surface); }
.ws-hub-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--surface); }
.ws-hub-skel { height: 56px; border-radius: var(--radius); }
.ws-hub-skel:first-child { height: 24px; width: 40%; }
.ws-hub-error { align-items: center; justify-content: center; text-align: center; gap: 8px; }
.ws-hub-error .ws-empty-icon { color: var(--danger); width: 40px; height: 40px; }
.ws-hub-error .ws-muted { max-width: 48ch; overflow-wrap: anywhere; }
.ws-hub-error .btn { margin-top: 8px; }

/* ================================================================ SETUP (settings page) */
.ws-settings { display: flex; flex-direction: column; }
.ws-sec { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 16px 48px; padding: 32px 0; border-top: 1px solid var(--border); align-items: start; }
.ws-sec:first-child { border-top: 0; padding-top: 8px; }
.ws-sec-intro { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ws-sec-intro .mono { font-size: 13px; color: var(--text); }
.ws-sec-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.ws-sec-card { padding: 0; overflow: hidden; min-width: 0; }
.ws-sec-body { padding: 24px; }
.ws-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }

.ws-rows { list-style: none; margin: 0; padding: 0; }
.ws-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 16px; min-height: 52px; }
.ws-row + .ws-row { border-top: 1px solid var(--border); }
.ws-row:hover { background: var(--hover, var(--surface-2)); }
.ws-row-icon { color: var(--text-3); display: inline-flex; flex: none; }
.ws-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ws-row-id { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.ws-row-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-del { color: var(--text-3); flex: none; }
.ws-del:hover { color: var(--danger); }

.ws-sec-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.ws-sec-foot:has(> .ws-inline-form:not([hidden])) { padding: 20px 16px 16px; background: var(--surface-2); }
.ws-addtoggle { align-self: flex-start; }

/* ================================================================ TABLES (register + probes) */
.ws-reg-summary { font-size: 13px; color: var(--text-2); min-height: 20px; margin-top: -8px; }
.ws-reg-summary .mono { color: var(--text); font-weight: 500; }
.ws-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1); overflow-x: auto; }
.ws-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ws-table th { height: 40px; padding: 0 16px; text-align: left; font-size: 13px; font-weight: 500; color: var(--text-2); text-transform: none; letter-spacing: 0; white-space: nowrap; border-bottom: 1px solid var(--border); background: transparent; }
.ws-table td { padding: 12px 16px; vertical-align: top; border-bottom: 1px solid var(--border); }
.ws-table tbody tr:last-child td { border-bottom: 0; }
.ws-table tbody tr:hover td { background: var(--hover, var(--surface-2)); }
.ws-num { text-align: right !important; }
.ws-c-item, .ws-c-probe { min-width: 240px; }
.ws-item-name { display: block; font-weight: 500; color: var(--text); }
.ws-item-meta { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; max-width: 64ch; }
.ws-c-due { white-space: nowrap; }
.ws-date { display: block; font-size: 13px; color: var(--text); }
.ws-days { display: inline-block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.ws-days[data-tone="warm"] { color: var(--warn); }
.ws-days[data-tone="hot"], .ws-days[data-tone="over"] { color: var(--danger); font-weight: 500; }
.ws-c-owner { overflow-wrap: anywhere; font-size: 13px; color: var(--text-2); }
.ws-c-act { width: 1%; padding-top: 8px !important; padding-bottom: 8px !important; }
.ws-row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.ws-row-actions .btn { color: var(--text-3); }
.ws-row-actions .btn:hover { color: var(--text); }
.ws-row-actions .ws-del:hover { color: var(--danger); }

/* severity: text + a small dot, colour only as a second signal */
.ws-sev { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); text-transform: capitalize; white-space: nowrap; }
.ws-sev::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex: none; }
.ws-sev[data-sev="medium"]::before { background: var(--warn); }
.ws-sev[data-sev="high"]::before { background: var(--stage-escalate, var(--warn)); }
.ws-sev[data-sev="high"] { color: var(--text); }
.ws-sev[data-sev="critical"]::before { background: var(--danger); }
.ws-sev[data-sev="critical"] { color: var(--text); font-weight: 500; }

/* ---------- dialog (shadcn Dialog) ---------- */
.ws-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.ws-dialog::backdrop { background: rgba(0, 0, 0, .4); }
:root[data-theme="dark"] .ws-dialog::backdrop { background: rgba(0, 0, 0, .6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ws-dialog::backdrop { background: rgba(0, 0, 0, .6); } }
.ws-dialog[open] { animation: ws-in .15s ease-out; }
.ws-dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.ws-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 24px 16px 0 24px; }
.ws-dialog-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ws-dialog-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.ws-dialog-x { color: var(--text-2); margin-top: -6px; }
.ws-dialog-body { padding: 20px 24px; overflow-y: auto; }
.ws-dialog-foot { display: flex; align-items: center; gap: 8px; padding: 0 24px 24px; }
.ws-dialog-del { color: var(--text-2); }
.ws-dialog-del:hover { color: var(--danger); }
@keyframes ws-in { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ================================================================ PROBES */
.ws-probe-tally { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--text-2); min-height: 20px; margin-top: -8px; }
.ws-probe-tally .mono { color: var(--text); font-weight: 500; }
.ws-tally { display: inline-flex; align-items: center; gap: 6px; }
.ws-src { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; color: var(--text); }
.ws-src > .ws-ico { color: var(--text-3); }
.ws-c-auth { font-size: 13px; color: var(--text-2); min-width: 140px; }
.ws-status { gap: 6px; white-space: nowrap; color: var(--text); }
.ws-probe-last { display: block; margin-top: 4px; font-size: 12px; color: var(--text-3); }
.ws-probe-table tr[data-tone="off"] .ws-item-name,
.ws-probe-table tr[data-tone="off"] .ws-item-meta { color: var(--text-3); }
.ws-probe-need { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.ws-probe-need svg { color: var(--warn); }
.ws-probe-need a { font-weight: 500; }
.ws-probe-err { margin-top: 8px; }
.ws-probe-err summary { cursor: pointer; font-size: 13px; color: var(--danger); width: max-content; }
.ws-probe-err summary:focus-visible { outline: 2px solid var(--text-3); outline-offset: 2px; border-radius: 2px; }
.ws-probe-err p { margin-top: 8px; font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border); padding: 8px; border-radius: var(--radius-sm); max-width: 64ch; }

/* ================================================================ responsive */
@media (max-width: 960px) {
  .ws-sec { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 24px 0; }
}
@media (max-width: 820px) {
  .ws-conn-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  /* tables become stacked rows */
  .ws-table-wrap { overflow: visible; }
  .ws-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ws-table, .ws-table tbody, .ws-table tr, .ws-table td { display: block; width: 100%; }
  .ws-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .ws-table tbody tr:last-child { border-bottom: 0; }
  .ws-table td { padding: 0 !important; border: 0 !important; min-width: 0; text-align: left !important; }
  .ws-table tbody tr:hover td { background: transparent; }
  .ws-table td.ws-c-item, .ws-table td.ws-c-probe { grid-column: 1 / -1; min-width: 0; margin-bottom: 4px; }
  .ws-reg-table td.ws-c-item { grid-column: 1; }
  .ws-table td.ws-c-act { grid-column: 2; grid-row: 1; width: auto; }
  .ws-table td:not(.ws-c-item):not(.ws-c-probe):not(.ws-c-act) { grid-column: 1 / -1; display: flex; gap: 12px; align-items: baseline; font-size: 13px; }
  .ws-table td:not(.ws-c-item):not(.ws-c-probe):not(.ws-c-act)::before { content: attr(data-label); width: 80px; flex: none; color: var(--text-3); font-size: 12px; font-family: var(--font-sans); font-weight: 400; }
  .ws-table .ws-date { display: inline; margin-right: 8px; }
  .ws-table .ws-probe-last { display: inline; margin: 0 0 0 8px; }
}
@media (max-width: 560px) {
  .ws-form-grid { grid-template-columns: minmax(0, 1fr); }
  .ws-title { font-size: 20px; }
  .ws-conn-card { padding: 16px; }
  .ws-sec-body { padding: 16px; }
  .ws-card-foot { padding: 12px 16px; }
  .ws-hub-body { height: 560px; }
  .ws-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .ws-dialog-head { padding: 20px 12px 0 16px; }
  .ws-dialog-body { padding: 16px; }
  .ws-dialog-foot { padding: 0 16px 16px; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .ws-dialog[open] { animation: none; }
}

/* controls on the muted add-form background keep the page surface so they don't read as disabled */
.ws-sec-foot .input, .ws-sec-foot .select, .ws-sec-foot .textarea { background-color: var(--surface); }

/* AI providers (Connections) */
.ws-ai-sec { margin-top: 32px; }
.ws-ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.ws-ai-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1); min-width: 0; }
.ws-ai-name { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 14px; font-weight: 500; }
.ws-ai-sub { font-size: 12px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-ai-card .ws-connstate { flex: none; }
.ws-ai-foot { margin-top: 12px; font-size: 13px; }

/* switch row (Setup → GitHub repositories) */
.ws-toggle-row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--border); cursor: pointer; }
.ws-toggle-text { display: flex; flex-direction: column; gap: 2px; flex: 1; font-size: 14px; font-weight: 500; }
.ws-toggle-text .ws-muted { font-size: 13px; font-weight: 400; }
.ws-toggle { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; border-radius: 999px; margin: 0;
  background: var(--surface-3); position: relative; cursor: pointer; transition: background .15s; }
.ws-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.ws-toggle:checked { background: var(--accent); }
.ws-toggle:checked::after { transform: translateX(16px); background: var(--accent-contrast); }
.ws-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.ws-toggle:disabled { opacity: .5; }
