/*
 * Status dos serviços — Trilha CuboPlus (INFRA-02).
 *
 * Sem framework, sem fonte externa, sem CDN: a página tem que abrir rápido e não
 * pode depender de mais nada estar no ar. Segue os tokens visuais do slide-trilha
 * (azul de marca #2E63E6, cartões arredondados, system-ui) com um tema claro
 * equivalente — quem abre uma página de status muitas vezes está no celular, no
 * sol, com pressa.
 */

/* ── Tokens: claro (padrão) ───────────────────────────────────────────────── */
:root {
  --bg: #f4f7fc;
  --bg-accent: #e7edfa;
  --card: #ffffff;
  --line: #dbe3f0;
  --txt: #101a2e;
  --muted: #5b6a85;
  --blue: #2e63e6;
  --blue-ink: #ffffff;

  --ok: #12794b;
  --warn: #a55a00;
  --bad: #c02626;
  --none: #5d6b83;

  --shadow: 0 8px 24px rgba(16, 26, 46, 0.08);
  --radius: 18px;
  --radius-sm: 11px;
}

/* ── Tokens: escuro ───────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --bg: #0d1428;
    --bg-accent: #16213d;
    --card: #141d33;
    --line: #26324f;
    --txt: #eaf0ff;
    --muted: #9fb0d0;
    --blue: #6b8df2;
    --blue-ink: #0d1428;

    --ok: #4ec98a;
    --warn: #f2b134;
    --bad: #ff6b6b;
    --none: #93a4c2;

    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme='dark'] {
  --bg: #0d1428;
  --bg-accent: #16213d;
  --card: #141d33;
  --line: #26324f;
  --txt: #eaf0ff;
  --muted: #9fb0d0;
  --blue: #6b8df2;
  --blue-ink: #0d1428;

  --ok: #4ec98a;
  --warn: #f2b134;
  --bad: #ff6b6b;
  --none: #93a4c2;

  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(1100px 480px at 50% -140px, var(--bg-accent) 0%, var(--bg) 70%);
  background-repeat: no-repeat;
  color: var(--txt);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 28px 0 8px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 36px 0 12px;
}

h3 { font-size: 1rem; margin: 0; }

p { margin: 0 0 12px; }

a { color: var(--blue); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-accent);
  padding: 1px 5px;
  border-radius: 5px;
}

.lead { color: var(--muted); max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
[hidden] { display: none !important; }

:where(a, button):focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--card);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  z-index: 10;
}
.skip:focus { left: 20px; }

/* ── Topo ─────────────────────────────────────────────────────────────────── */
.topbar { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--card) 55%, transparent); }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.brand { font-size: 0.95rem; letter-spacing: 0.4px; color: var(--muted); }
.brand b { color: var(--blue); }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ghost-btn:hover { color: var(--txt); border-color: var(--blue); }

/* ── Banner do estado geral ───────────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  margin: 20px 0 8px;
}

.banner-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--blue-ink);
  background: var(--none);
}

.banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.banner-text strong { font-size: 1.12rem; line-height: 1.3; }

.banner-operacional { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.banner-operacional .banner-icon { background: var(--ok); }
.banner-degradado { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.banner-degradado .banner-icon { background: var(--warn); }
.banner-indisponivel { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.banner-indisponivel .banner-icon { background: var(--bad); }
.banner-sem_dados .banner-icon,
.banner-loading .banner-icon { background: var(--none); }

/* ── Cartões ──────────────────────────────────────────────────────────────── */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-desc { color: var(--muted); font-size: 0.88rem; margin: 2px 0 0; }

/* Faixa lateral só quando há algo errado — cartão verde não precisa gritar. */
.card-degradado { border-left: 4px solid var(--warn); }
.card-indisponivel { border-left: 4px solid var(--bad); }
.card-sem_dados { border-left: 4px solid var(--none); }

.skeleton { height: 96px; }
.skeleton span {
  display: block;
  height: 14px;
  width: 40%;
  border-radius: 6px;
  background: var(--line);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.45; } }

/* ── Pílula de estado (nunca só cor: tem glifo + texto) ───────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.pill-operacional { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill-degradado { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill-indisponivel { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pill-sem_dados { color: var(--none); background: color-mix(in srgb, var(--none) 12%, transparent); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-operacional { background: var(--ok); }
.dot-degradado { background: var(--warn); }
.dot-indisponivel { background: var(--bad); }
.dot-sem_dados { background: var(--none); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 14px 2px 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; }

/* ── Barras de disponibilidade ────────────────────────────────────────────── */
.uptime { margin-top: 14px; }

.bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 30px;
  overflow: hidden;
}

.bar {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  border-radius: 2px;
  background: var(--none);
  opacity: 0.35;
}
.bar-ok { background: var(--ok); opacity: 1; }
.bar-warn { background: var(--warn); opacity: 1; }
.bar-bad { background: var(--bad); opacity: 1; }

.uptime-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Em telas estreitas mostramos menos dias — 90 barras de 1px não informam nada. */
@media (max-width: 600px) {
  .bar:nth-child(-n + 45) { display: none; }
}
@media (max-width: 380px) {
  .bar:nth-child(-n + 60) { display: none; }
}

/* ── Incidentes e manutenção ──────────────────────────────────────────────── */
.timeline { list-style: none; margin: 10px 0 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 12px 14px; position: relative; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.timeline time { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.timeline .status { font-weight: 700; }

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 6px;
}

.notice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--muted);
}

/* ── Rodapé ───────────────────────────────────────────────────────────────── */
.foot {
  margin: 44px auto 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Movimento reduzido ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
