/* Components — spec §6.2–§6.5 (sidebar) and §7.1–§7.17. */

/* ─── Sidebar (§6.1–§6.5) ──────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-logo {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.02em;
}

.sidebar-logo-sub {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) 0;
}

.sidebar-nav-item {
  display: block;
  padding: var(--sp-2) var(--sp-4);
  font-size: 11px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.sidebar-nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
  text-decoration: none;
}

.sidebar-nav-item.active {
  color: var(--green);
  border-left-color: var(--green);
  background: var(--green-bg);
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 7.1 Buttons ──────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--btn-h);
  padding: 0 var(--sp-4);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid;
  border-radius: 0;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: oklch(72% 0.16 140);
  border-color: oklch(72% 0.16 140);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--bg-raised);
}

.btn-danger {
  background: transparent;
  border-color: var(--red-dim);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-bg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

/*
 * .btn-link (Pass D.6) — navigation-style button. Blue text + blue-dim
 * border at rest; blue-bg fill on hover. Visual treatment matches
 * `.drawer-close` (Pass D.5), which opened the "navigation = blue"
 * convention. Used for the list view's "See more" anchor; future
 * navigation surfaces (sidebar, tab anchors) may follow the convention.
 */
.btn-link {
  background: transparent;
  border-color: var(--blue-dim);
  color: var(--blue);
}

.btn-link:hover {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.btn-sm {
  height: 26px;
  padding: 0 var(--sp-3);
  font-size: 10px;
}

.btn-full {
  width: 100%;
}

/* ─── 7.2 Inputs ───────────────────────────────────────── */

.field {
  margin-bottom: var(--sp-3);
}

.field-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.input,
.select {
  display: block;
  width: 100%;
  height: var(--input-h);
  padding: 0 var(--sp-3);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  transition: border-color var(--transition);
}

.input::placeholder {
  color: var(--text-dim);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.input:disabled,
.select:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}

.input-error {
  border-color: var(--red-dim);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.field-hint {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: var(--sp-1);
}

.field-error-msg {
  font-size: 10px;
  color: var(--red);
  margin-top: var(--sp-1);
}

/* ─── 7.3 Badges & Lamps ───────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px var(--sp-2);
  border: 1px solid;
  letter-spacing: 0.04em;
  border-radius: 0;
}

.badge-ok {
  color: var(--green);
  border-color: var(--green-dim);
  background: var(--green-bg);
}

.badge-warn {
  color: var(--amber);
  border-color: var(--amber-dim);
  background: var(--amber-bg);
}

.badge-error {
  color: var(--red);
  border-color: var(--red-dim);
  background: var(--red-bg);
}

.badge-info {
  color: var(--blue);
  border-color: var(--blue-dim);
  background: var(--blue-bg);
}

.badge-muted {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-raised);
}

/* Lamps use border-radius: 50% — the one documented exception to §1's no-radius rule. */
.lamp {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.lamp-ok {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}

.lamp-warn {
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber);
}

.lamp-error {
  background: var(--red);
  box-shadow: 0 0 4px var(--red);
}

.lamp-off {
  background: var(--text-dim);
}

/* ─── 7.4 Alert Banners ────────────────────────────────── */

.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid;
  font-size: 11px;
  margin-bottom: var(--sp-3);
}

.alert-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.alert-ok {
  background: var(--green-bg);
  border-left-color: var(--green);
  color: var(--green);
}

.alert-warn {
  background: var(--amber-bg);
  border-left-color: var(--amber);
  color: var(--amber);
}

.alert-error {
  background: var(--red-bg);
  border-left-color: var(--red);
  color: var(--red);
}

.alert-info {
  background: var(--blue-bg);
  border-left-color: var(--blue);
  color: var(--blue);
}

/* ─── 7.5 Metrics Row ──────────────────────────────────── */

.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--border);
}

.metric {
  padding: var(--sp-4);
  border-right: 1px solid var(--border);
}

.metric:last-child {
  border-right: none;
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
}

.metric-value.ok    { color: var(--green); }
.metric-value.warn  { color: var(--amber); }
.metric-value.error { color: var(--red); }

/* ─── 7.6 Table ────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table td {
  font-size: 11px;
  color: var(--text-primary);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border-dim);
  vertical-align: middle;
}

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

.table tr:hover td {
  background: var(--bg-raised);
}

.url-cell   { color: var(--green); }
.muted-cell { color: var(--text-muted); }

/* ─── 7.7 Tabs ─────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
}

.tab {
  font-size: 11px;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* ─── 7.8 Code / Diff Block ────────────────────────────── */

.code-block {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: var(--sp-4);
  font-size: 10px;
  font-family: inherit;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.diff-add  { color: var(--green); }
.diff-rem  { color: var(--red); }
.diff-meta { color: var(--text-dim); }
.diff-hunk { color: var(--amber); }

/* ─── 7.9 Panel ────────────────────────────────────────── */

.panel {
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.panel-header {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.panel-body {
  padding: var(--sp-4);
}

/* ─── 7.10 Expander ────────────────────────────────────── */

.expander {
  border: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}

.expander-trigger {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  font-size: 11px;
  font-family: inherit;
  color: var(--text-muted);
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border: none;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.expander-trigger:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.expander-chevron {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
}

.expander-chevron::after { content: '▼'; }
.expander.open .expander-chevron::after { content: '▲'; }

.expander-body {
  padding: var(--sp-4);
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  display: none;
}

.expander.open .expander-body {
  display: block;
}

/* ─── 7.11 Checkbox ────────────────────────────────────── */

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
}

.checkbox-box {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkbox-box.checked {
  background: var(--green-bg);
  border-color: var(--green-dim);
}

.checkbox-box.checked::after {
  content: '✓';
  font-size: 9px;
  color: var(--green);
  font-weight: 700;
}

/* ─── 7.12 Radio Chip Group ────────────────────────────── */

.radio-group {
  display: flex;
  gap: 0;
}

.radio-chip {
  padding: var(--sp-1) var(--sp-3);
  font-size: 10px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  margin-right: -1px;
  background: none;
  font-family: inherit;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.radio-chip:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.radio-chip.active {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-color: var(--text-primary);
  position: relative;
  z-index: 1;
}

/* ─── 7.14 Drawer ──────────────────────────────────────── */

.drawer {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  padding: var(--sp-5) var(--sp-4);
  margin: 0 -1px;
}

.drawer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.drawer-url {
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 500;
}

.drawer-subtext {
  font-size: 11px;
  color: var(--green);
  margin-top: 2px;
}

.drawer-close {
  border: 1px solid var(--blue-dim);
  color: var(--blue);
  font-size: 10px;
  padding: 2px var(--sp-2);
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.drawer-close:hover {
  border-color: var(--blue);
  background: var(--blue-bg);
}

/* ─── 7.15 History Feed ────────────────────────────────── */

.history-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-dim);
  gap: var(--sp-4);
}

.history-row:last-child {
  border-bottom: none;
}

.history-meta {
  font-size: 11px;
  color: var(--text-primary);
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.history-meta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-sub {
  font-size: 10px;
  color: var(--text-dim);
}

.history-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-shrink: 0;
}

.history-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.change-label    { color: var(--amber); font-weight: 500; }
.baseline-label  { color: var(--blue);  font-weight: 500; }
.reversion-label { color: var(--amber); font-weight: 500; }
.nochange-label  { color: var(--text-muted); }

/* ─── 7.16 Site Row ────────────────────────────────────── */
/*
 * Pass D.5 column structure (7 columns):
 *   Status · Display name · Domain · Last checked · Last change · Checks · See more
 *
 * Status is leftmost for failure-spotting accessibility — a vertical
 * scan strip down the column finds non-OK rows fast. The redundant
 * Pass C "Last status" column has been dropped (the Status badge
 * already encodes the HTTP code as text).
 */

.site-row {
  display: grid;
  grid-template-columns: 110px 1fr 2.4fr 1.2fr 1.2fr 70px 120px;
  align-items: center;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-dim);
  gap: var(--sp-3);
}

.site-row:hover {
  background: var(--bg-raised);
}

.site-row-header {
  display: grid;
  grid-template-columns: 110px 1fr 2.4fr 1.2fr 1.2fr 70px 120px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
}

.site-name { color: var(--text-primary); font-size: 11px; font-weight: 500; }
.site-url  { color: var(--green); font-size: 11px; }
.site-meta { font-size: 10px; color: var(--text-muted); }

/*
 * Pass D.6 failed-row state. A site whose most-recent check returned
 * an error (4xx/5xx HTTP, network failure, decode failure) renders
 * with a red background tint, redirected colors on Domain + metadata
 * cells, and (via the template) a badge-error variant override.
 *
 * The display_name (`.site-name`) keeps `--text-primary` deliberately:
 * it is the user's identifier, and tinting it red would muddy
 * recognition. Red applies to the technical address (display_url),
 * the metadata, and the badge — three redundant signals so
 * color-blind users get the badge text and screen-reader users get
 * the status code/label.
 *
 * `color-mix` requires Safari 16.2+ / Chrome 111+ / Firefox 113+ —
 * within RoboFender's target browser range. If a future browser
 * support concern surfaces, the fallback is a static --red-bg-hover
 * token.
 */
.site-row-failed             { background: var(--red-bg); border-bottom-color: var(--red-dim); }
.site-row-failed:hover       { background: color-mix(in oklch, var(--red-bg), var(--red) 14%); }
.site-row-failed .site-url a { color: var(--red); }
.site-row-failed .site-meta  { color: var(--red-dim); }

/* ─── 7.17 Dividers ────────────────────────────────────── */

.divider {
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

.divider-dim {
  border-top: 1px solid var(--border-dim);
  margin: var(--sp-4) 0;
}

/* ─── Auth wrap (referenced by §10.2/§10.3, used in Pass A) ── */

.auth-wrap {
  max-width: 360px;
  margin: 0 auto;
  padding: var(--sp-8) 0;
}

/* ─── 7.18 Modal (Pass D.5) ────────────────────────────── */
/*
 * Type-to-confirm dialog for destructive actions. Hidden via the
 * standard [hidden] HTML attribute so the show/hide toggle is a
 * one-liner in JS without class-name juggling. Sharp corners per
 * --radius:0 align with the rest of the design system.
 */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: var(--sp-6);
  max-width: 480px;
  width: 100%;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-3);
}

.modal-body {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

/* ─── 7.19 Inspection Mode (Pass D.6) ──────────────────── */
/*
 * Banner + subtitle render above the 5-stat row when the detail view
 * is in inspection mode (?snapshot= and ?from_check= both resolve).
 * The banner identifies which version is being inspected and offers
 * a "Back to live" link styled per the navigation = blue convention.
 * The subtitle narrates the version's activation history.
 */

.inspection-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--text-muted);
  background: var(--bg-raised);
  margin-bottom: var(--sp-3);
  gap: var(--sp-3);
}

.inspection-banner-text {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.inspection-banner-back {
  font-size: 10px;
  color: var(--blue);
  border: 1px solid var(--blue-dim);
  padding: 2px var(--sp-2);
  background: none;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.inspection-banner-back:hover {
  border-color: var(--blue);
  background: var(--blue-bg);
}

.inspection-subtitle {
  font-size: 11px;
  margin-bottom: var(--sp-4);
  line-height: 1.5;
}

.inspection-subtitle-lead {
  color: var(--text-primary);
}

.inspection-subtitle-context {
  color: var(--text-muted);
  margin-left: var(--sp-1);
}
