/*
 * Trabalance Status Page — static styles
 *
 * Designed to load instantly with no external fonts, no external assets,
 * and no JavaScript framework. The whole page is one HTML file + this CSS
 * + one JS file. ~10KB total over the wire.
 */

* {
  box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.1);
  --green-border: rgba(74, 222, 128, 0.25);
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, 0.1);
  --yellow-border: rgba(250, 204, 21, 0.25);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.1);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.1);
  --red-border: rgba(248, 113, 113, 0.25);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.1);
  --blue-border: rgba(96, 165, 250, 0.25);
  --slate: #94a3b8;
  --slate-soft: #1e293b;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ─── Header ─────────────────────────────────────────────────────────── */

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

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

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.brand-tagline {
  font-size: 14px;
  color: var(--text-muted);
}

.header-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.header-link:hover {
  color: var(--text);
}

/* ─── Loading state ──────────────────────────────────────────────────── */

.state-loading,
.state-error {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Error state ────────────────────────────────────────────────────── */

.error-icon {
  font-size: 48px;
  color: var(--orange);
  margin-bottom: 12px;
}

.state-error h2 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 18px;
}

.state-error p {
  max-width: 480px;
  margin: 0 auto 20px;
}

.retry-button {
  padding: 8px 20px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.retry-button:hover {
  background: #1d4ed8;
}

/* ─── Overall banner ─────────────────────────────────────────────────── */

.overall-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  margin-bottom: 32px;
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  border-radius: 12px;
}

.overall-banner.is-degraded {
  background: var(--yellow-soft);
  border-color: var(--yellow-border);
}

.overall-banner.is-partial {
  background: var(--orange-soft);
  border-color: #fed7aa;
}

.overall-banner.is-major {
  background: var(--red-soft);
  border-color: var(--red-border);
}

.overall-banner.is-maintenance {
  background: var(--blue-soft);
  border-color: var(--blue-border);
}

.overall-banner.is-unknown {
  background: var(--slate-soft);
  border-color: var(--border);
}

.overall-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
}

.overall-banner.is-degraded .overall-dot { background: var(--yellow); }
.overall-banner.is-partial .overall-dot { background: var(--orange); }
.overall-banner.is-major .overall-dot { background: var(--red); animation: pulse 2s infinite; }
.overall-banner.is-maintenance .overall-dot { background: var(--blue); }
.overall-banner.is-unknown .overall-dot { background: var(--slate); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#overall-label {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--green);
}

.overall-banner.is-degraded #overall-label { color: #854d0e; }
.overall-banner.is-partial #overall-label { color: #9a3412; }
.overall-banner.is-major #overall-label { color: #991b1b; }
.overall-banner.is-maintenance #overall-label { color: #1e40af; }
.overall-banner.is-unknown #overall-label { color: var(--text-muted); }

/* ─── Sections ───────────────────────────────────────────────────────── */

.section {
  margin-bottom: 40px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

/* ─── Maintenance ────────────────────────────────────────────────────── */

.maintenance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.maintenance-item {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--blue-soft);
  border: 1px solid var(--blue-border);
  border-radius: 8px;
}

.maintenance-item.is-in-progress {
  background: var(--yellow-soft);
  border-color: var(--yellow-border);
}

.maintenance-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue);
  margin-bottom: 4px;
}

.maintenance-item.is-in-progress .maintenance-tag {
  color: var(--yellow);
}

.maintenance-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.maintenance-description {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.maintenance-window {
  font-size: 12px;
  color: var(--text-subtle);
  margin: 8px 0 0;
}

/* ─── Uptime chart ───────────────────────────────────────────────────── */

.uptime-section {
  padding: 24px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.uptime-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.uptime-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.uptime-summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
}

.uptime-chart {
  display: flex;
  gap: 2px;
  height: 36px;
  align-items: stretch;
  margin-bottom: 8px;
}

.uptime-bar {
  flex: 1;
  border-radius: 2px;
  background: var(--green);
  min-width: 2px;
}

.uptime-bar.is-degraded { background: var(--yellow); }
.uptime-bar.is-outage { background: var(--red); }
.uptime-bar.is-empty { background: var(--border); }

.uptime-axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 12px;
}

.uptime-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-up { background: var(--green); }
.legend-degraded { background: var(--yellow); }
.legend-outage { background: var(--red); }

/* ─── Component list ─────────────────────────────────────────────────── */

.component-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

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

.component-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.component-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.component-dot.is-degraded { background: var(--yellow); }
.component-dot.is-partial { background: var(--orange); }
.component-dot.is-major { background: var(--red); }
.component-dot.is-maintenance { background: var(--blue); }
.component-dot.is-unknown { background: var(--slate); }

.component-text {
  min-width: 0;
}

.component-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.component-description {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.component-status {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--green);
}

.component-status.is-degraded { color: var(--yellow); }
.component-status.is-partial { color: var(--orange); }
.component-status.is-major { color: var(--red); }
.component-status.is-maintenance { color: var(--blue); }
.component-status.is-unknown { color: var(--slate); }

/* ─── Incidents ──────────────────────────────────────────────────────── */

.incidents-block {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.incident-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.incident-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.incident-item:first-child {
  padding-top: 0;
}

.incident-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

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

.severity-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 8px;
}

.severity-critical { background: var(--red-soft); color: var(--red); }
.severity-major { background: var(--orange-soft); color: var(--orange); }
.severity-minor { background: var(--yellow-soft); color: var(--yellow); }

/* ─── Past incidents ─────────────────────────────────────────────────── */

.past-incidents {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.past-incident-group {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.past-incident-group:last-child {
  border-bottom: none;
}

.past-incident-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.past-incident-item {
  padding: 0;
}

.past-incident-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.past-incident-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.past-incident-badge.resolved {
  background: var(--green-soft);
  color: var(--green);
}

.past-incident-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.past-incident-detail {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 6px;
}

.past-incident-time {
  font-size: 12px;
  color: var(--text-subtle);
  margin: 0;
}

/* ─── Footer ─────────────────────────────────────────────────────────── */

.footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.last-checked {
  font-size: 12px;
  color: var(--text-subtle);
  margin: 0 0 8px;
}

.copyright {
  font-size: 12px;
  color: var(--text-subtle);
  margin: 0;
}

/* ─── Mobile ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .page {
    padding: 20px 16px 60px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .overall-banner {
    padding: 18px;
  }

  #overall-label {
    font-size: 17px;
  }

  .uptime-section {
    padding: 18px;
  }

  .component-row {
    padding: 14px 16px;
  }
}
