/* ============================================================
   Mixbound Admin — Design System
   ============================================================ */

:root {
  --brand-orange: 24 95% 53%;
  --brand-coral:  10 85% 57%;
  --brand-pink:   340 82% 52%;
  --gradient-primary: linear-gradient(135deg, hsl(24,95%,53%) 0%, hsl(10,85%,57%) 50%, hsl(340,82%,52%) 100%);

  --bg:         hsl(220, 14%, 98%);
  --surface:    hsl(0, 0%, 100%);
  --fg:         hsl(220, 14%, 10%);
  --muted:      hsl(220, 14%, 96%);
  --muted-fg:   hsl(220, 9%, 46%);
  --primary:    hsl(24, 95%, 53%);
  --primary-soft: hsla(24, 95%, 53%, 0.1);
  --destructive: hsl(0, 84%, 60%);
  --success:    hsl(142, 71%, 45%);
  --border:     hsl(220, 13%, 91%);

  --radius-sm: 0.375rem;
  --radius:    0.5rem;
  --radius-lg: 0.75rem;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
img, svg { display: block; max-width: 100%; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; color: var(--fg); line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }

/* ─── Layout ─────────────────────────────────────────────── */
.container { width: 100%; max-width: 1052px; margin: 0 auto; padding: 0 1.5rem; }

.page {
  padding: 2rem 0 3rem;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; }
.page-header .subtitle { color: var(--muted-fg); font-size: 0.9375rem; margin-top: 0.25rem; }

/* ─── Admin header ───────────────────────────────────────── */
.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem;
}
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4rem;
  gap: 2rem;
  flex-wrap: wrap;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--fg);
}
.admin-brand img {
  height: 36px;
  width: auto;
  display: block;
}
.admin-brand span {
  font-weight: 600;
  color: var(--muted-fg);
  font-size: 24px;
  line-height: 22px;
}
.admin-brand:hover { text-decoration: none; }

.admin-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.admin-links a {
  display: inline-flex;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--muted-fg);
}
.admin-links a:hover { background: var(--muted); color: var(--fg); text-decoration: none; }
.admin-links a.is-active { background: var(--primary-soft); color: var(--primary); }

.admin-user {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.875rem;
}
.admin-user-email { color: var(--muted-fg); }

.admin-footer {
  padding: 2rem 0;
  font-size: 0.875rem;
  color: var(--muted-fg);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline {
  background: var(--surface); color: var(--fg); border-color: var(--border);
}
.btn-outline:hover { background: var(--muted); }
.btn-ghost {
  background: transparent; color: var(--muted-fg);
}
.btn-ghost:hover { color: var(--fg); background: var(--muted); }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1rem; }

.btn-group { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── Cards / panels ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.card-header h2 { font-size: 1.125rem; }
.card-body > * + * { margin-top: 1rem; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-stack > * + * { margin-top: 1.25rem; }
.form-row { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row-2 { grid-template-columns: 1fr 1fr; } }

.form-field { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.875rem; font-weight: 500; color: var(--fg); }
.form-label .req { color: var(--destructive); }
.form-help  { font-size: 0.8125rem; color: var(--muted-fg); }

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-textarea { resize: vertical; min-height: 6rem; font-family: inherit; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--muted-fg); }
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-error-text { font-size: 0.8125rem; color: var(--destructive); }

.checkbox {
  display: inline-flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font-size: 0.9375rem;
}
.checkbox input { width: 1rem; height: 1rem; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-fg);
  background: var(--bg);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--muted); }
.table .col-actions { text-align: right; white-space: nowrap; }

/* ─── Badges / pills ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--muted); color: var(--muted-fg);
}
.badge-success { background: hsla(142, 71%, 45%, 0.12); color: hsl(142, 71%, 30%); }
.badge-danger  { background: hsla(0, 84%, 60%, 0.12);   color: hsl(0, 60%, 40%); }
.badge-primary { background: var(--primary-soft);        color: var(--primary); }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  border: 1px solid transparent;
}
.alert-success { background: hsla(142,71%,45%,0.1); color: hsl(142,71%,25%); border-color: hsla(142,71%,45%,0.3); }
.alert-error   { background: hsla(0,84%,60%,0.1); color: hsl(0,60%,35%); border-color: hsla(0,84%,60%,0.3); }
.alert-info    { background: var(--primary-soft); color: var(--primary); border-color: hsla(24,95%,53%,0.3); }

/* ─── Auth (login) page ──────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.auth-card .subtitle { color: var(--muted-fg); font-size: 0.9375rem; margin-bottom: 1.5rem; }
.auth-card .btn { width: 100%; }
.auth-card .form-divider {
  margin: 1.5rem 0;
  text-align: center;
  color: var(--muted-fg);
  font-size: 0.8125rem;
  position: relative;
}
.auth-card .form-divider::before,
.auth-card .form-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-card .form-divider::before { left: 0; }
.auth-card .form-divider::after  { right: 0; }

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-brand img {
  height: 2.25rem;
  width: auto;
  display: inline-block;
}

/* ─── Utilities ──────────────────────────────────────────── */
.text-muted { color: var(--muted-fg); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.is-hidden { display: none !important; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 0.875rem; }

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted-fg);
}
.empty-state p + p { margin-top: 0.5rem; }

/* ─── Tabs (underlined, page-level sub-nav) ──────────────── */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 0.125rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: -1px;           /* overlap the strip's bottom border */
  color: var(--muted-fg);
  font-size: 0.9375rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
  transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.tab:hover {
  color: var(--fg);
  background: var(--muted);
  text-decoration: none;
}
.tab[aria-selected="true"],
.tab.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-bottom-color: var(--primary);
}
.tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.375rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-fg);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.tab:hover .tab-count { background: var(--border); }
.tab[aria-selected="true"] .tab-count,
.tab.is-active .tab-count {
  background: hsl(24, 95%, 90%);
  color: var(--primary);
}

/* ─── Status badges ──────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--muted-fg);
  margin-right: 0.375rem;
  vertical-align: middle;
}
.status-dot.is-online   { background: var(--success); box-shadow: 0 0 0 3px hsla(142, 71%, 45%, 0.15); }
.status-dot.is-stopped  { background: var(--muted-fg); }
.status-dot.is-errored  { background: var(--destructive); box-shadow: 0 0 0 3px hsla(0, 84%, 60%, 0.15); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.stat {
  background: var(--muted);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
}
.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-fg);
}
.stat-value {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--fg);
  margin-top: 0.125rem;
}

/* ─── Activity list (overview tab) ───────────────────────── */
.activity-list { display: grid; gap: 0.625rem; }
.activity-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  background: var(--surface);
}
.activity-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.activity-line {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.8125rem;
  color: var(--fg);
  background: var(--muted);
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.activity-line.is-empty {
  color: var(--muted-fg);
  font-style: italic;
  background: transparent;
  padding-left: 0;
}

/* ─── Log viewer ─────────────────────────────────────────── */
.log-block {
  background: hsl(220, 14%, 10%);
  color: hsl(220, 14%, 90%);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre;
  max-height: 360px;
  overflow-y: auto;
}
.log-block.is-empty {
  color: var(--muted-fg);
  background: var(--muted);
  font-style: italic;
  white-space: normal;
}
.log-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted-fg);
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
}
.log-stream-tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--muted);
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 0.5rem;
}
.log-stream-tag.is-error { background: hsl(0, 84%, 95%); color: hsl(0, 60%, 35%); }
