/* dataico.css — agent-boxes component layer.
   Loaded AFTER tokens.css. Maps the app's existing class hooks
   (defined in views/layout.tsx) onto brand tokens. Light/Mist theme.
   Only restyles existing hooks — never deletes or renames a class. */

/* Reset the default UA body margin so the header bleeds edge-to-edge
   (tokens.css styles <body> but does not zero its margin). */
body { margin: 0; }

/* ---------- Header / top nav ---------- */
header {
  background: var(--bg-strong);
  color: var(--text-inverse);
  /* Align the header's inner content gutter with <main>: full-bleed
     background, but content edges track the centered grid-max column. */
  padding-block: var(--space-3);
  padding-inline: calc(max(0px, (100% - var(--grid-max)) / 2) + var(--grid-gutter-d));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  flex-wrap: wrap;
  border-bottom: var(--stroke-thin) solid var(--dark--10);
}

/* The two header clusters (brand+nav, user+signout). Defined here rather
   than in layout.tsx's inline <style>, where JSX escapes `>` to `&gt;`
   inside the raw-text <style> element and the rule is silently dropped. */
header > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

header a {
  color: var(--text-inverse);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--fs-body-sm);
  line-height: 1;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}

header a:hover,
header a:focus-visible,
header a.active {
  color: var(--brand-coral);
}

header span {
  color: var(--text-inverse);
  opacity: 0.75;
  font-size: var(--fs-body-sm);
  line-height: 1;
  white-space: nowrap;
}

/* Right cluster: keep the email and the Sign-out button on one centered line */
header form.inline { display: inline-flex; align-items: center; margin: 0; }
header span { display: inline-flex; align-items: center; }

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-7) var(--grid-gutter-d) var(--space-6);
  margin-top: var(--space-6);
  opacity: 0.8;
}
.site-footer img { display: block; }

/* ---------- Main container ---------- */
main {
  max-width: var(--grid-max);
  margin: var(--space-6) auto;
  padding: 0 var(--grid-gutter-d);
}

@media (max-width: 768px) {
  main { padding: 0 var(--grid-gutter-m); }
  header { padding-inline: var(--grid-gutter-m); }
}

/* ---------- Vertical rhythm ----------
   Headings reset to margin:0 in tokens.css; restore page-level spacing
   so titles don't sit flush against the first card/section. */
main > h1 { margin-bottom: var(--space-5); }
main h2 { margin-bottom: var(--space-3); }
main > p { margin: 0 0 var(--space-4); }

summary {
  cursor: pointer;
  font-weight: var(--fw-medium);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* A table inside a .card must not carry its own card chrome — the
   wrapping .card (padding:0; overflow:hidden) supplies the frame. */
.card table {
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

th, td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--stroke-thin) solid var(--gris-3);
  text-align: left;
  vertical-align: middle;
}

/* Keep status pills and action controls on one line per cell. */
td .status { white-space: nowrap; }

/* Compact action controls inside table cells — keep buttons, selects,
   inputs and chips on a single consistent height so rows line up. */
td button, td .btn, td select, td input {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-caption);
}
td .chip { font-size: var(--fs-caption); }

/* Row action group: lay buttons out in a wrapping flex row with a
   consistent gap instead of letting inline forms collide. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.actions form.inline { display: inline-flex; margin: 0; }

th {
  background: var(--gris-1);
  color: var(--text-default);
  font-weight: var(--fw-bold);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: var(--stroke-thin) solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--text-default);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover, .btn:hover {
  background: var(--gris-1);
  border-color: var(--gris-50);
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-coral);
  color: var(--brand-white);
  border-color: var(--brand-coral);
}

.btn-primary:hover {
  background: var(--coral-6);
  border-color: var(--coral-6);
}

button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Inputs ---------- */
input, select, textarea {
  padding: var(--space-2) var(--space-3);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  color: var(--text-default);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  line-height: 1.4;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-coral);
  box-shadow: 0 0 0 2px var(--coral-1);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ---------- Status pills ----------
   Base extends the .pill primitive from tokens.css. */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  line-height: 1;
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  border: var(--stroke-thin) solid transparent;
}

.status-created {
  background: var(--gris-2);
  color: var(--gris-7);
  border-color: var(--gris-3);
}

.status-starting {
  background: var(--accent-lime--1);
  color: var(--gris-8);
  border-color: var(--accent-lime-2);
}

.status-running {
  background: var(--accent-lime);
  color: var(--gris-9);
  border-color: var(--accent-lime-2);
}

.status-stopping {
  background: var(--coral-1);
  color: var(--coral-8);
  border-color: var(--coral-2);
}

.status-stopped {
  background: var(--gris-2);
  color: var(--gris-7);
  border-color: var(--gris-4);
}

.status-terminating {
  background: var(--coral-2);
  color: var(--coral-9);
  border-color: var(--coral-7);
}

.status-terminated {
  background: var(--gris-3);
  color: var(--gris-7);
  border-color: var(--gris-4);
}

/* ---------- Spinner (htmx transitional) ---------- */
.spinner {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  margin-right: 0.35em;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.htmx-request .spinner { opacity: 1; }

/* ---------- Host-health card ---------- */
.host-health {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-5);
  align-items: baseline;
  flex-wrap: wrap;
}

.host-health b {
  color: var(--text-default);
  font-weight: var(--fw-bold);
}

/* ---------- Live machine-metrics panel (home page) ---------- */
.metrics {
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
}
.metrics__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.metrics__title {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  color: var(--text-default);
}
.metrics__sub {
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4) var(--space-5);
}
.metric { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.metric__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}
.metric__label {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.metric__pct {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  color: var(--text-default);
}
.metric__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}
.metric__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.metric__net {
  display: flex;
  gap: var(--space-4);
  color: var(--text-default);
}
.metric__net b { font-weight: var(--fw-bold); }
.metric__detail {
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
}

/* ---------- Live box-status panel (task detail) ---------- */
.box-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3) var(--space-5);
  margin: 0;
}
.box-status-grid > div { min-width: 0; }
.box-status-grid dt {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.box-status-grid dd {
  margin: 0;
  color: var(--text-default);
  word-break: break-word;
}

/* ---------- Generic card helper (for later view tasks) ---------- */
.card {
  background: var(--bg-surface);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

/* ---------- Inline form helper (already used in markup) ---------- */
form.inline { display: inline; }

/* ---------- Dashboard hero / welcome banner ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: var(--space-5);
  background: var(--bg-surface);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--space-5);
}
.hero__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-6);
}
.hero__eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-caption);
  font-weight: var(--fw-bold);
  color: var(--brand-coral);
}
.hero__title { margin: 0; }
.hero__title--mark { display: inline-flex; align-items: center; gap: var(--space-3); }
.hero__title--mark .ab-mark { flex: 0 0 auto; overflow: visible; }
.hero__lead { margin: 0; color: var(--text-muted); max-width: 34rem; }
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.hero__art { position: relative; min-height: 200px; }
.hero__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center right;
}
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero__art { min-height: 160px; order: -1; }
  .hero__art img { position: static; }
}

/* ---------- Status summary cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat__value {
  font-family: var(--font-display);
  font-size: var(--fs-display-lg, 2rem);
  line-height: 1;
  font-weight: 500;
}
.stat__label {
  color: var(--text-muted);
  font-size: var(--fs-body-sm);
}
@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Home navigation cards ---------- */
.navcards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.navcard {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: var(--stroke-thin) solid var(--border-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text-default);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.navcard:hover {
  border-color: var(--coral-3);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.navcard__icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--coral-1);
  border-radius: var(--r-md);
  margin-bottom: var(--space-1);
}
.navcard__icon img { width: 26px; height: 26px; }
.navcard__title { font-family: var(--font-display); font-size: var(--fs-title-md, 1.5rem); }
.navcard__desc { color: var(--text-muted); font-size: var(--fs-body-sm); flex: 1; }
.navcard__go { color: var(--brand-coral); font-weight: var(--fw-bold); font-size: var(--fs-body-sm); }

/* ---------- Empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6);
  margin: var(--space-4) 0;
}
.empty__art {
  width: 100%;
  max-width: 520px;
  height: auto;
  border-radius: var(--r-md);
}
