/* Connection management and first-run onboarding.
   Owned by the connections workstream. Every colour is a custom property from
   app.css so light and dark mode both work; nothing here is hard-coded.
   All new class names are prefixed `cx-` so they cannot collide with the
   shared design system or another workstream's stylesheet. */

/* ---------- shared bits ---------- */

.cx-pill-neutral {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line-strong);
}

/* A status pill that opens the connection health panel. */
.cx-pill-button {
  font-family: inherit;
  line-height: 1.5;
  cursor: pointer;
}
.cx-pill-button:hover { filter: brightness(1.05); text-decoration: underline; }
.cx-pill-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cx-mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* The environment card gained a third action, so it has to wrap on a narrow
   grid column instead of overflowing the card. */
.env-card .env-actions { flex-wrap: wrap; }

.cx-btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.cx-btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* The confirmed, irreversible action. --bg is dark in dark mode and light in
   light mode, so it stays readable on --danger in both. */
.cx-btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--bg);
}
.cx-btn-danger-solid:hover { filter: brightness(1.07); }

.cx-callout-note {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

/* ---------- dialog ---------- */

.cx-dialog-title { word-break: break-word; }
.cx-dialog-body { display: grid; gap: 0; }
.cx-loading { padding: 8px 0 12px; }

.cx-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-bottom: 14px;
}

.cx-banner { margin-bottom: 4px; }

.cx-section { border-top: 1px solid var(--line); padding: 14px 0; }
.cx-section:last-child { padding-bottom: 0; }
.cx-section > h3 {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.cx-kv { display: grid; gap: 8px; margin: 0; }
.cx-kv > div {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: baseline;
}
.cx-kv dt { font-size: 11px; color: var(--muted); }
.cx-kv dd { margin: 0; font-size: 13px; word-break: break-word; }
.cx-kv dd small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.cx-health-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 12px; }
.cx-health-head .muted { flex: 1; min-width: 0; }

.cx-error-box {
  margin-top: 12px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  border-radius: 0 6px 6px 0;
  padding: 9px 12px;
}
.cx-error-box strong { font-size: 11px; color: var(--danger); }
.cx-error-text { color: var(--danger); font-size: 12px; line-height: 1.5; margin-top: 3px; }

.cx-subblock { margin-top: 14px; }
.cx-subblock > strong { font-size: 12px; display: block; }
.cx-subblock > .muted { margin-top: 3px; }

.cx-perm-list {
  list-style: none;
  margin: 9px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cx-perm-list li { display: flex; }

.cx-remediation {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 9px;
  line-height: 1.5;
}

.cx-collector-list { list-style: none; margin: 9px 0 0; padding: 0; display: grid; gap: 7px; }
.cx-collector-list li {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 10px;
}
.cx-collector-list strong { font-size: 12px; }

.cx-test-slot:empty { display: none; }
.cx-test-result {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 11px 12px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  line-height: 1.5;
}
.cx-test-result.cx-test-error { border-color: var(--danger); }
.cx-test-result.cx-test-warning { border-color: var(--warn); }
.cx-test-result.cx-test-healthy { border-color: var(--ok); }
.cx-test-head { display: flex; align-items: baseline; gap: 9px; }
.cx-test-head > span:last-child { flex: 1; min-width: 0; }
.cx-test-result .link { justify-self: start; }

.cx-readonly-note { margin-top: 14px; }

.dialog-foot.cx-foot-split { justify-content: space-between; }
.cx-foot-left, .cx-foot-right { display: flex; gap: 8px; }

/* ---------- edit form ---------- */

.cx-form > .field-label:first-child { margin-top: 0; }
.cx-inline-error { min-height: 0; margin-top: 6px; }
.cx-inline-error:empty { display: none; }

.cx-regions { margin-top: 5px; }
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; min-height: 26px; }
.cx-chips-empty { align-self: center; }

.cx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 3px 2px 10px;
  color: var(--ink);
}
.cx-chip-remove {
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
}
.cx-chip-remove:hover { background: var(--danger-soft); color: var(--danger); }
.cx-chip-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.cx-region-add { display: flex; gap: 8px; align-items: center; }
.cx-region-add input { flex: 1; min-width: 0; }
.cx-region-add .btn { flex: none; }

.cx-delete-lede { font-size: 13px; line-height: 1.55; margin-bottom: 14px; }

/* ---------- onboarding ---------- */

.block.cx-onboarding {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 34px;
  align-items: start;
  padding: 34px 32px;
}

.cx-onboarding-intro > .eyebrow { display: block; margin-bottom: 9px; }
.cx-onboarding h1 { font-size: 25px; margin-bottom: 10px; }
.cx-onboarding-lede {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.65;
  max-width: 48ch;
}

.cx-onboarding-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.cx-onboarding-primary { padding: 10px 18px; font-size: 14px; }
.cx-onboarding-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.cx-onboarding-note { max-width: 48ch; margin-top: 12px; }

.cx-steps-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.cx-steps-panel > .eyebrow { display: block; }
.cx-steps.steps { list-style: none; padding: 0; margin: 14px 0 0; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .block.cx-onboarding { grid-template-columns: 1fr; gap: 24px; padding: 24px 20px; }
  .cx-onboarding h1 { font-size: 21px; }
}

@media (max-width: 560px) {
  .cx-kv > div { grid-template-columns: 1fr; }
  .cx-kv dt { font-weight: 600; }
  .dialog-foot.cx-foot-split { flex-wrap: wrap; gap: 8px; }
  .cx-foot-right { flex-wrap: wrap; }
  .cx-onboarding-actions .btn { width: 100%; justify-content: center; }
}
