/* ── Reset & Base ─────────────────────────────────────────────────────────── */

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

:root {
  --bg: #080c10;
  --bg-surface: rgba(255, 255, 255, 0.03);
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --text: #e8f0fa;
  --text-muted: #7a8fa6;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.15);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --font: 'Inter', system-ui, sans-serif;
  --radius: 12px;
  --radius-lg: 20px;
}

[data-theme="light"] {
  --bg: #f3f7fb;
  --bg-surface: #ffffff;
  --bg-elevated: rgba(16, 32, 46, 0.04);
  --text: #10202e;
  --text-muted: #5c7286;
  --border: rgba(16, 32, 46, 0.10);
  --border-strong: rgba(16, 32, 46, 0.18);
}

body.status-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

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

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

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

.brand-icon {
  font-size: 1.4rem;
}

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

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

.last-checked {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-refresh {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.btn-refresh:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-refresh.spinning {
  animation: spin 0.8s linear infinite;
}

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

/* ── Overall Status ────────────────────────────────────────────────────────── */

.overall-status {
  text-align: center;
  margin-bottom: 36px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 24px;
}

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

.status-dot.operational { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status-dot.degraded    { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.status-dot.down        { background: var(--red); box-shadow: 0 0 6px var(--red); }

.status-label {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Component Grid ─────────────────────────────────────────────────────────── */

.component-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.component-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.component-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

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

.component-dot.operational { background: var(--accent); }
.component-dot.degraded    { background: var(--amber); }
.component-dot.down        { background: var(--red); }

.component-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.component-latency {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.component-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Uptime Section ─────────────────────────────────────────────────────────── */

.uptime-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.uptime-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.uptime-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.uptime-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent), #0099cc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
}

.uptime-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Active Incident Banner ─────────────────────────────────────────────────── */

.incident-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 32px;
}

.incident-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.incident-text {
  font-size: 0.88rem;
  color: #fca5a5;
  font-weight: 500;
}

/* ── Incident Log ───────────────────────────────────────────────────────────── */

.incident-log {
  margin-bottom: 48px;
}

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

.incident-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.incident-table {
  width: 100%;
  border-collapse: collapse;
}

.incident-table th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.incident-table td {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.incident-table tbody tr:last-child td {
  border-bottom: none;
}

.incident-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.loading-row td,
.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

.inc-component {
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.inc-status {
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 10px;
}

.inc-status-operational {
  background: var(--accent-dim);
  color: var(--accent);
}

.inc-status-degraded {
  background: var(--amber-dim);
  color: var(--amber);
}

.inc-status-down {
  background: var(--red-dim);
  color: var(--red);
}

/* ── Subscribe Section ──────────────────────────────────────────────────────── */

.subscribe-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  margin-bottom: 48px;
}

.subscribe-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.subscribe-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 10px;
}

.subscribe-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.subscribe-form {
  display: flex;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
}

.subscribe-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.subscribe-input::placeholder {
  color: var(--text-muted);
}

.subscribe-input:focus {
  border-color: var(--accent);
}

.subscribe-btn {
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  color: #04151d;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.subscribe-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.subscribe-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.subscribe-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.subscribe-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.success-check {
  font-size: 1.2rem;
}

.subscribe-error {
  color: #fca5a5;
  font-size: 0.85rem;
  margin-top: 12px;
}

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

.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.footer-sep {
  opacity: 0.4;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .container {
    padding: 32px 16px 64px;
  }

  .component-grid,
  .uptime-grid {
    grid-template-columns: 1fr;
  }

  .subscribe-form {
    flex-direction: column;
  }

  .subscribe-form .subscribe-btn {
    width: 100%;
  }

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