/* Instance grid + cards (selectors preserved: .vm-grid / .vm-card / .vm-* ) */

.vm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.vm-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .12s;
}
.vm-card:hover { border-color: var(--border-strong); }

/* Dual-node hosts (2× DGX Spark): green left accent bar + green gpu value so
   the beefier host stands out at a glance, echoing the "running" badge green. */
.vm-card-dual {
  border-color: var(--green-dim);
  box-shadow: inset 3px 0 0 var(--green);
}
.vm-card-dual:hover { border-color: var(--green); }
.vm-card-dual .vm-meta-row[title="gpu profile"] .vm-meta-value {
  color: var(--green);
  font-weight: 500;
}

/* Pre-book dedicated host (spark-1-prebook): blue left accent — same pattern as
   dual, keyed to the pre-book UI's blue so reserved windows stand out vs on-demand. */
.vm-card-prebook {
  border-color: var(--blue-dim);
  box-shadow: inset 3px 0 0 var(--blue);
}
.vm-card-prebook:hover { border-color: var(--blue); }
.vm-card-prebook .vm-meta-row[title="gpu profile"] .vm-meta-value {
  color: var(--blue);
  font-weight: 500;
}

.vm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.vm-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-0);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Outlined-only badge: subtle dot + colored text + matching border */
.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px 1px 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid currentColor;
  flex-shrink: 0;
  color: var(--text-2);
}
.badge::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}
.badge-running { color: var(--green); }
.badge-exited  { color: var(--yellow); }
.badge-created { color: var(--blue); }
.badge-paused  { color: var(--purple); }
.badge-unknown { color: var(--text-3); }   /* spark unreachable — status not verifiable */
.badge-loading { color: var(--text-3); }   /* roster known, agent still being polled */
.badge-loading::before { animation: badge-pulse 1.4s ease-in-out infinite; }
.badge-provisioning { color: var(--blue); } /* launched, booting — cleared once seen running */
.badge-provisioning::before { animation: badge-pulse 1.4s ease-in-out infinite; }
@keyframes badge-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

.vm-provisioning-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.vm-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}

/* Single-line "key  macbook-2026" row on each instance card */
.vm-meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  min-width: 0;
}
.vm-meta-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  min-width: 52px;     /* fits the longest label currently used ("waited"); */
  flex-shrink: 0;      /* short labels (gpu, key) still left-align to the same column */
}
.vm-meta-value {
  flex: 1;
  min-width: 0;        /* allow the value to shrink and ellipse instead of pushing the row wider */
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ssh-block {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: border-color .12s;
}
.ssh-block:hover { border-color: var(--border-strong); }
.ssh-block code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ssh-block .copy-label {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.ssh-block.copied .copy-label { color: var(--green); }

.vm-actions {
  display: flex;
  gap: 7px;
  margin-top: auto;
}

/* Empty state ------------------------------------------------------------ */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: transparent;
}
.empty-state-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-2);
  margin-bottom: 16px;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 4px;
}
.empty-state-sub {
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 20px;
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
}

/* Error state ------------------------------------------------------------ */

.error-state {
  text-align: center;
  padding: 40px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
}
.error-state p:first-child {
  font-size: 14px;
  color: var(--text-0);
  margin-bottom: 6px;
  font-weight: 500;
}
.error-state p {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
  max-width: 60ch;
  margin-left: auto;
  margin-right: auto;
}
.error-state code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-deep);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.error-state .retry-btn { margin-top: 14px; }

@media (max-width: 720px) {
  .vm-grid { grid-template-columns: 1fr; }
  .empty-state { padding: 44px 20px; }
}

/* Inline create panel --------------------------------------------------- */

.create-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  padding: 16px 18px 18px;
  margin-bottom: 18px;
}
.create-panel[hidden] { display: none; }
/* Hide the "no instances" empty-state while the create panel is open —
   the panel is the user's next action, no need to also surface the
   empty-state CTA. Pops back automatically when the panel is closed. */
.create-panel:not([hidden]) ~ #vm-list .empty-state { display: none; }
.create-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.create-panel-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-0);
}
.create-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.create-form fieldset.form-group {
  border: 0;
  padding: 0;
}
.create-form fieldset.form-group legend {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 7px;
  padding: 0;
}

/* GPU radio list */
.gpu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gpu-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-deep);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
/* Author `display: flex` above beats the UA `[hidden]` rule — restore it. */
.gpu-row[hidden] { display: none; }
.gpu-row:hover { border-color: var(--border-strong); }
.gpu-row:has(input:checked) {
  border-color: var(--text-2);
  background: var(--bg-2);
}
.gpu-row input[type="radio"] {
  accent-color: var(--text-0);
  width: 14px;
  height: 14px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}
.gpu-row-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.gpu-row-name {
  font-size: 13px;
  color: var(--text-0);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.gpu-row-meta {
  font-size: 11.5px;
  color: var(--text-2);
}
.gpu-row-price {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin-left: 12px;
  flex-shrink: 0;
}
.gpu-row-price-unit {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0;
  margin-left: 1px;
}
.gpu-row-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
  border: 1px solid currentColor;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
/* Restore the [hidden] attribute over the flex display above — JS hides
   this row when the queue-offer panel takes over. */
.form-actions[hidden] { display: none; }

@media (max-width: 720px) {
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
}

/* SSH key picker (inside create panel) ---------------------------------- */

.ssh-key-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ssh-key-picker[hidden] { display: none; }
.ssh-key-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 2px;
}
.ssh-key-delete-link {
  color: var(--text-3);
}
.ssh-key-delete-link:hover {
  color: var(--red);
  text-decoration-color: var(--red);
}

.ssh-key-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-deep);
  margin-top: 8px;
}
.ssh-key-add-form[hidden] { display: none; }
.ssh-key-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* Restart-in-progress visual state ------------------------------------- */

/* Screen-reader-only label (kept in markup for a11y, hidden visually) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Animated three-dot loader — terminal-feel, used inside the restart
   button while the stop+start chain is in flight. Three spans blink in
   sequence rather than animating `content`, for cross-browser reliability. */
.dots {
  display: inline-flex;
  gap: 1px;
  font-family: var(--mono);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
}
.dots > span {
  animation: dot-blink 1.4s infinite;
  opacity: 0.15;
}
.dots > span:nth-child(2) { animation-delay: 0.2s; }
.dots > span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink {
  0%, 100% { opacity: 0.15; }
  40%, 60% { opacity: 1; }
}

/* Restart-in-progress badge: blue reads as "transitioning, working"
   (distinct from green=running, yellow=exited, gray=unknown). */
.badge-restarting { color: var(--blue); }
/* Delete-in-progress badge: red signals "being torn down". The pulsing
   dot reuses the same cue as the loading/provisioning badges. */
.badge-deleting { color: var(--red); }
.badge-deleting::before { animation: badge-pulse 1.4s ease-in-out infinite; }
/* Waitlist queue badge: yellow signals "pending action / not yet real". */
.badge-waiting { color: var(--yellow); }

/* Waitlist cards live alongside instance cards in the vm-grid. Dashed
   border + slight bg shift signals "not a real instance yet — this is a
   queued request." Less visual weight than a running container. */
.vm-card-waiting {
  background: var(--bg-deep);
  border-style: dashed;
  position: relative;
}

/* Info icon in the bottom-right corner of a waitlist card. Click toggles
   a small popover explaining what the queue is and why we ask users to
   stay on it. Anchored to the card via position: relative on .vm-card-waiting. */
.vm-waitlist-info-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  border-radius: 50%;
  opacity: 0.85;
  transition: opacity .12s, transform .12s;
}
.vm-waitlist-info-btn:hover,
.vm-waitlist-info-btn:focus-visible { opacity: 1; transform: scale(1.06); outline: none; }
.vm-waitlist-info-btn svg { width: 16px; height: 16px; display: block; }

.vm-waitlist-info-popover[hidden] { display: none; }
.vm-waitlist-info-popover {
  position: absolute;
  right: 10px;
  bottom: 34px;
  z-index: 5;
  width: min(280px, calc(100% - 20px));
  padding: 10px 12px 10px 12px;
  padding-right: 28px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-1);
}
.vm-waitlist-info-popover p { margin: 0; }
.vm-waitlist-info-popover p + p { margin-top: 8px; color: var(--text-2); }

.vm-waitlist-info-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--text-3);
  cursor: pointer;
  transition: color .12s, background .12s;
}
.vm-waitlist-info-close:hover,
.vm-waitlist-info-close:focus-visible {
  color: var(--text-0);
  background: var(--bg-2);
  outline: none;
}
.vm-waitlist-info-close svg { width: 12px; height: 12px; display: block; }

/* Long-wait callout — shown at the bottom of a waitlist card once the
   entry has been pending past LONG_WAIT_THRESHOLD_MS. Replaces the info
   icon for the duration; ends with a CTA to /pre-book. */
.vm-waitlist-longwait {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--yellow) 6%, transparent);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-1);
}
.vm-waitlist-longwait-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vm-waitlist-longwait-icon { display: inline-flex; }
.vm-waitlist-longwait-icon svg { width: 14px; height: 14px; display: block; }
.vm-waitlist-longwait-title { font-weight: 600; }
.vm-waitlist-longwait p { margin: 0; color: var(--text-2); }
.vm-waitlist-longwait-price {
  color: var(--yellow);
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
}
/* Same amber highlight the price used, for the "July 1st" capacity date. */
.vm-waitlist-longwait-date {
  color: var(--yellow);
  font-weight: 600;
  white-space: nowrap;
}
.vm-waitlist-longwait-cta {
  align-self: flex-start;
  margin-top: 2px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-deep);
  background: var(--yellow);
  border: 1px solid var(--yellow);
  border-radius: var(--radius);
  text-decoration: none;
  transition: filter .12s, transform .12s;
}
.vm-waitlist-longwait-cta:hover,
.vm-waitlist-longwait-cta:focus-visible {
  filter: brightness(1.08);
  transform: translateY(-1px);
  outline: none;
}

/* Subtle dim on the whole card while it's busy, so the disabled state of
   the action buttons doesn't look broken — the card itself signals "wait". */
.vm-card-busy { opacity: 0.92; }

/* Usage view --------------------------------------------------------- */

.usage-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  overflow: hidden;
}
.usage-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr 1.2fr 0.8fr;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  align-items: baseline;
}
.usage-row:last-child { border-bottom: 0; }
.usage-row-head {
  background: var(--bg-deep);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 16px;
}
.usage-row-active { background: rgba(88, 166, 255, 0.04); }

.usage-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-1);
}
.usage-cell-time,
.usage-cell-duration {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
}
.usage-cell-label {
  display: none;          /* shown on mobile only */
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
}

.usage-name {
  font-family: var(--mono);
  color: var(--text-0);
  font-weight: 500;
}
.usage-name-orphan { color: var(--text-3); }
.usage-deleted {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}
.usage-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-deep);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.usage-active {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 12.5px;
}

/* Mobile: stack into labeled rows */
@media (max-width: 720px) {
  .usage-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 14px;
  }
  .usage-row-head { display: none; }
  .usage-cell-label { display: inline-block; }
  .usage-cell-name { font-size: 14px; padding-bottom: 2px; }
}

/* Queue offer (replaces form-actions when create hits MAX_RUNNING_VMS) */

.queue-offer {
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.queue-offer[hidden] { display: none; }
.queue-offer-msg {
  font-size: 13px;
  color: var(--text-1);
  line-height: 1.55;
}
.queue-offer-msg strong {
  font-family: var(--mono);
  color: var(--text-0);
  font-weight: 500;
}
.queue-offer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Usage view — waitlist history sub-section ---------------------------- */

.usage-subhead {
  margin: 36px 0 12px;
}
.usage-subhead h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
  letter-spacing: -0.005em;
}
.usage-subhead p {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.55;
  margin-top: 4px;
  max-width: 60ch;
}

/* The waitlist table has 6 columns instead of 5; override the grid. */
.waitlist-history-table .usage-row {
  grid-template-columns: 1.4fr 1fr 1.1fr 1.1fr 0.7fr 0.8fr;
}

.waitlist-outcome {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  text-transform: lowercase;
}
.waitlist-outcome-fulfilled { color: var(--green); }
.waitlist-outcome-cancelled { color: var(--text-3); }
.waitlist-outcome-expired   { color: var(--yellow); }

@media (max-width: 720px) {
  .waitlist-history-table .usage-row { grid-template-columns: 1fr; }
}

/* Pager for the usage + waitlist-history tables. Sits flush under the
   table, right-aligned, with neutral chrome so the data stays the focus. */
.usage-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 2px 0;
  font-size: 12px;
  color: var(--text-2);
}
.usage-pager-label {
  font-family: var(--mono);
  letter-spacing: 0.02em;
  min-width: 80px;
  text-align: center;
}
