/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  /* Hug label — never stretch to a flex/grid parent (e.g. `.field` column). */
  width: max-content;
  max-width: 100%;
  flex: 0 0 auto;
  align-self: flex-start;
  padding: calc(var(--space-1)) calc(var(--space-2) + 2px);
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  /* Small-caps token: body÷1.5, semibold, 1px tracking. */
  font-size: var(--ui-text-badge);
  line-height: 1;
  letter-spacing: var(--ui-tracking-caps, 1px);
  font-weight: 600;
  text-transform: uppercase;
}

/* Same type as `.badge` — no pill chrome (`StatusBadge bare`). */
.badge-label {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--ui-text-badge);
  line-height: 1;
  letter-spacing: var(--ui-tracking-caps, 1px);
  font-weight: 600;
  text-transform: uppercase;
}

.badge-label.clean {
  color: var(--success);
}

.badge-label.warn {
  color: var(--danger);
}

.badge-label.caution {
  color: var(--warning);
}

.badge-label.alert {
  color: var(--caution);
}

.badge.running,
.badge.dirty {
  /* In-progress / notice — chrome outline, semantic text as a tint. */
  border-color: var(--border);
}

.badge.running {
  color: color-mix(in srgb, var(--running) 32%, var(--text-muted));
  background: color-mix(in srgb, var(--running) 8%, transparent);
}

/* Pass / fail (and accepted / rejected) must stay opposite hues.
   Do not mix them into --text-muted — chrome hue collapses the pair.
   Error / fail pills are solid fill (darkened danger + white label ≥ 4.5:1). */
.badge.warn {
  color: #fff;
  background: color-mix(in srgb, var(--danger) 55%, black);
  border-color: color-mix(in srgb, var(--danger) 55%, black);
}

.badge.clean {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border-color: color-mix(in srgb, var(--success) 50%, transparent);
}

.badge.caution {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  border-color: color-mix(in srgb, var(--warning) 50%, transparent);
}

.badge.alert {
  color: var(--caution);
  background: color-mix(in srgb, var(--caution) 14%, transparent);
  border-color: color-mix(in srgb, var(--caution) 50%, transparent);
}

.badge.dirty {
  color: color-mix(in srgb, var(--warning) 32%, var(--text-muted));
  background: color-mix(in srgb, var(--warning) 8%, transparent);
}

/* Circular count — same diameter; mid-size digits, optically centered. */
.badge.count {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  min-width: calc(5 * var(--u));
  width: calc(5 * var(--u));
  height: calc(5 * var(--u));
  /* Digits have no descenders; geometric center sits ink high — nudge down. */
  padding: 0.08em 0 0;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  /* Between body÷1.5 (too large in the circle) and body÷2 (too small). */
  font-size: calc(var(--ui-text-xs) / 1.75);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
  text-transform: none;
}

/* Entity row / status-strip framed messages (sentence case; no trailing «.»).
   Prefer one line — hug content; only wrap when the parent is truly too narrow. */
.entity-row-message {
  box-sizing: border-box;
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: var(--ui-text-xs);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  text-align: start;
}
/* Narrow parents only: allow wrap so copy stays readable. */
@container (max-width: calc(40 * var(--u))) {
  .entity-row-message {
    white-space: normal;
  }
}
.entity-row-message--danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border-subtle));
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.entity-row-message--warn {
  color: color-mix(in srgb, var(--warning) 40%, var(--text));
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border-subtle));
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}
.entity-row-message--muted {
  color: var(--text-muted);
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

/* Panels */

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-outer);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.pane-panel {
  height: 100%;
  min-height: 0;
  border-radius: 0;
  border: none;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
}

.pane-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.panel-header-end {
  justify-content: flex-end;
}

.panel-actions {
  display: inline-flex;
  gap: var(--space-2);
}

/* Resizable shell splits (columns / rows) — pairs with ResizableSplit */

.split-shell {
  display: grid;
  height: 100%;
  min-height: 0;
  min-width: 0;
}

.split-shell-dragging {
  user-select: none;
  cursor: inherit;
}

.split-shell-dragging.split-shell-horizontal,
.split-shell-dragging .split-handle-col {
  cursor: col-resize;
}

.split-shell-dragging.split-shell-vertical,
.split-shell-dragging .split-handle-row {
  cursor: row-resize;
}

.split-primary,
.split-secondary {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split-handle {
  background: var(--border-subtle);
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.split-handle::after {
  content: "";
  position: absolute;
  inset: -2px;
}

.split-handle-col {
  cursor: col-resize;
}

.split-handle-row {
  cursor: row-resize;
}

.split-handle:hover,
.split-shell-dragging .split-handle {
  background: var(--accent);
}

/* Status dot — pairs with the StatusDot component */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-stopped {
  background: var(--border);
}

.dot-pending {
  background: var(--warning);
}

.dot-running {
  background: var(--running);
}

.dot-blocked {
  background: var(--danger);
  opacity: 0.65;
}

.dot-crashed {
  background: var(--danger);
}

/* Empty state — centered in the pane body (vert + horiz), copy wraps. */

.empty-state {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  align-self: stretch;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: calc(12 * var(--u));
  height: 100%;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-4);
}

.empty-state p {
  max-width: min(100%, calc(90 * var(--u)));
  margin: 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

/* Scrollbars never occupy layout space. Classic gutters (macOS “Always”,
   Windows, Firefox `thin`) shift roster chrome when overflow appears —
   e.g. product → ingredients expand. Keep scroll via wheel/trackpad;
   do not paint a classic track. (Styling width:0 is intentional here:
   unstyled WebKit on “Always show scroll bars” still carves a gutter.) */

* {
  scrollbar-width: none;
  scrollbar-gutter: auto;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}

*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
  background: transparent;
  border: none;
}

/* Overlay thumbs — never classic system bars. Reveal color only while
   `.is-scrolling` (set by `install_scroll_indicators`). Keep width at 0 /
   `scrollbar-width: none` always so revealing a thumb cannot shift layout. */

.is-scrolling::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--text) 40%, transparent);
  border: none;
  border-radius: 9999px;
  /* Paint inside the zero-width gutter via box-shadow so layout stays put. */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 40%, transparent);
}

.is-scrolling::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--text) 50%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 50%, transparent);
}

/* Compact controls — same layout-neutral rule (no width / scrollbar-width flip). */
.ui-scroll-tiny.is-scrolling::-webkit-scrollbar-thumb {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 45%, transparent);
}

/* Circular panel spinner (first-paint only; named work uses the strip) */

.spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--u) * 6);
  height: calc(var(--u) * 6);
}

.spinner-ring {
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong, var(--border));
  border-top-color: var(--accent-strong, var(--text-muted));
  border-radius: 50%;
  animation: spinner-rotate 0.7s linear infinite;
}

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

.panel-spinner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-2) 0;
}

/* Floating notify hosts — growl (top), toast (bottom-left), snackbar (bottom-center). */

.notify-growls,
.notify-toasts,
.notify-snackbar-host {
  pointer-events: none;
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 var(--space-4);
}

.notify-growls {
  inset-inline: 0;
  top: var(--space-4);
  align-items: center;
}

.notify-toasts {
  left: var(--space-4);
  bottom: calc(var(--u) * 8 + var(--space-4));
  align-items: flex-start;
  max-width: min(360px, calc(100vw - 2rem));
}

.notify-snackbar-host {
  inset-inline: 0;
  bottom: calc(var(--u) * 8 + var(--space-4));
  align-items: center;
}

.notify-growl,
.notify-toast,
.notify-snackbar {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  width: 100%;
  max-width: 420px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: notify-enter 180ms ease-out;
}

.notify-toast {
  max-width: 360px;
}

.notify-snackbar {
  max-width: 480px;
}

@keyframes notify-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notify-growl,
  .notify-toast,
  .notify-snackbar {
    animation: none;
  }
}

.notify-growl.is-error,
.notify-toast.is-error,
.notify-snackbar.is-error {
  border-color: var(--danger);
}

.notify-growl.is-error .notify-message,
.notify-toast.is-error .notify-message {
  color: var(--danger);
  font-weight: 500;
}

.notify-toast.is-success .notify-message {
  color: var(--success);
}

.notify-message {
  flex: 1;
  min-width: 0;
}

.notify-action {
  flex-shrink: 0;
  margin: 0;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.notify-action:hover {
  border-color: var(--accent);
  color: var(--text);
}

.notify-dismiss {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}

.notify-dismiss:hover {
  opacity: 1;
}

