/* Lab Monitoring Dashboard — Dark Theme */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2333;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --text-bright: #f0f6fc;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --orange: #f0883e;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Header ─── */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-bright);
}

.header .version {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.status-badge.ok { background: rgba(63,185,80,0.15); color: var(--green); }
.status-badge.degraded { background: rgba(210,153,34,0.15); color: var(--yellow); }
.status-badge.error { background: rgba(248,81,73,0.15); color: var(--red); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.degraded { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-dot.error { background: var(--red); box-shadow: 0 0 6px var(--red); }

.last-update {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ─── Summary Cards ─── */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.2s;
}

.card:hover { background: var(--bg-card-hover); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-icon {
  font-size: 20px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-value.green { color: var(--green); }
.card-value.yellow { color: var(--yellow); }
.card-value.red { color: var(--red); }

/* ─── Sections ─── */
.sections {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-body {
  padding: 16px 20px;
}

/* ─── Server Cards ─── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.server-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: border-color 0.2s;
}

.server-card:hover { border-color: var(--blue); }

.server-card .name {
  font-weight: 600;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.server-card .host {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  text-align: center;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
  font-variant-numeric: tabular-nums;
}

.metric-value.ok { color: var(--green); }
.metric-value.warn { color: var(--yellow); }
.metric-value.crit { color: var(--red); }

/* ─── Site Rows ─── */
.site-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.site-row:last-child { border-bottom: none; }

.site-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-name {
  font-weight: 500;
  color: var(--text-bright);
}

.site-url {
  font-size: 12px;
  color: var(--text-muted);
}

.site-metrics {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.site-metric {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Service Grid ─── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.service-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.service-card .name {
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-card .detail {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.service-card .detail strong {
  color: var(--text);
  font-weight: 500;
}

/* ─── Alerts ─── */
.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.alert-row:last-child { border-bottom: none; }

.alert-severity {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-message {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.alert-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.alert-group {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-right: 8px;
}

.no-alerts {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

.no-alerts .icon { font-size: 32px; margin-bottom: 8px; }

/* ─── Loading / Error ─── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.loading .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.error-banner {
  background: rgba(248,81,73,0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 24px;
  color: var(--red);
  font-size: 14px;
  display: none;
}

/* ─── Footer ─── */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .summary { grid-template-columns: repeat(2, 1fr); padding: 16px; }
  .sections { padding: 0 16px 16px; }
  .server-grid { grid-template-columns: 1fr; }
  .service-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(3, 1fr); }
  .header { padding: 12px 16px; }
  .header h1 { font-size: 16px; }
}
