/* Página de status do Engaja Já. Cores em tokens: tema claro por padrão, escuro pelo aparelho
   (prefers-color-scheme) ou pela escolha da pessoa (data-theme no <html>). */

:root {
  color-scheme: light;
  --bg: #e9eeec;
  --surface: #f9fbfa;
  --surface-top: #f4f7f6;
  --surface-2: #e8eeec;
  --border: #d6e0de;
  --border-soft: #e1e8e6;
  --text: #0e2224;
  --text-soft: #3d5f61;
  --text-faint: #4d6d6f;
  --brand: #58c411;
  --brand-deep: #2d7206;
  --up: #43a524;
  --degraded: #d99a2b;
  --down: #c4534a;
  --nodata: #d3dcda;
  --up-bg: #dcebd0;
  --degraded-bg: #f6ead0;
  --down-bg: #f5dfdc;
  --unknown-bg: #e1e8e6;
  --on-state: #0e2224;
  --shadow: 0 1px 2px rgba(14, 34, 36, 0.06);
  --radius: 16px;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #081618;
    --surface: #0f2325;
    --surface-2: #142b2d;
    --border: #1c3638;
    --surface-top: #0b1c1e;
    --border-soft: #17302f;
    --on-state: #06120a;
    --text: #eef5f3;
    --text-soft: #a3bcbb;
    --text-faint: #6b8a89;
    --brand-deep: #9eea6c;
    --up: #6fd35a;
    --degraded: #f0bb5c;
    --down: #ff7d88;
    --nodata: #1f3a3c;
    --up-bg: rgba(88, 196, 17, 0.14);
    --degraded-bg: rgba(240, 187, 92, 0.14);
    --down-bg: rgba(255, 125, 136, 0.14);
    --unknown-bg: rgba(214, 230, 227, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081618;
  --surface: #0f2325;
  --surface-2: #142b2d;
  --border: #1c3638;
  --surface-top: #0b1c1e;
  --border-soft: #17302f;
  --on-state: #06120a;
  --text: #eef5f3;
  --text-soft: #a3bcbb;
  --text-faint: #6b8a89;
  --brand-deep: #9eea6c;
  --up: #6fd35a;
  --degraded: #f0bb5c;
  --down: #ff7d88;
  --nodata: #1f3a3c;
  --up-bg: rgba(88, 196, 17, 0.14);
  --degraded-bg: rgba(240, 187, 92, 0.14);
  --down-bg: rgba(255, 125, 136, 0.14);
  --unknown-bg: rgba(214, 230, 227, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
}

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

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-deep);
}

.wrap {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
}

.muted {
  color: var(--text-faint);
  font-size: 13px;
}

/* ---- Topo ---------------------------------------------------------------------------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-top) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand em {
  font-style: normal;
  font-weight: 500;
  color: var(--text-soft);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.link:hover {
  background: var(--surface-2);
}

.link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: block;
  }
}

/* ---- Faixa geral --------------------------------------------------------------------------------------------- */

main.wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 32px;
  padding-bottom: 32px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--unknown-bg);
  box-shadow: var(--shadow);
}

.banner h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3.4vw, 26px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.banner p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.banner-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--nodata);
  color: var(--on-state);
  position: relative;
}

.glyph {
  display: none;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 1;
}

.banner[data-state="operational"] .glyph-ok,
.banner[data-state="degraded"] .glyph-warn,
.banner[data-state="partial_outage"] .glyph-warn,
.banner[data-state="major_outage"] .glyph-down {
  display: block;
}

.banner-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  opacity: 0.35;
  animation: pulse 2.4s ease-out infinite;
}

.banner[data-state="operational"] {
  background: var(--up-bg);
  border-color: color-mix(in srgb, var(--up) 30%, var(--border));
}
.banner[data-state="operational"] .banner-icon {
  background: var(--up);
}
.banner[data-state="degraded"],
.banner[data-state="partial_outage"] {
  background: var(--degraded-bg);
  border-color: color-mix(in srgb, var(--degraded) 35%, var(--border));
}
.banner[data-state="degraded"] .banner-icon,
.banner[data-state="partial_outage"] .banner-icon {
  background: var(--degraded);
}
.banner[data-state="major_outage"] {
  background: var(--down-bg);
  border-color: color-mix(in srgb, var(--down) 35%, var(--border));
}
.banner[data-state="major_outage"] .banner-icon {
  background: var(--down);
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.35;
  }
  80%,
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .banner-icon::after {
    animation: none;
  }
}

/* ---- Resumo ------------------------------------------------------------------------------------------------ */

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---- Cartões ------------------------------------------------------------------------------------------------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.card-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -0.01em;
}

.legend {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 12px;
  color: var(--text-soft);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 6px;
}
.dot.up {
  background: var(--up);
}
.dot.degraded {
  background: var(--degraded);
}
.dot.down {
  background: var(--down);
}
.dot.nodata {
  background: var(--nodata);
}

/* ---- Serviços ------------------------------------------------------------------------------------------------ */

.services,
.incidents {
  list-style: none;
  margin: 0;
  padding: 0;
}

.service {
  padding: 18px 0;
  border-top: 1px solid var(--border-soft);
}

.service:first-child {
  border-top: 0;
}

.service-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.service-meta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.latency {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.spark {
  width: 88px;
  height: 28px;
  overflow: visible;
}

.spark polyline {
  fill: none;
  stroke: var(--up);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark circle {
  fill: var(--up);
}

.spark[data-health="degraded"] polyline {
  stroke: var(--degraded);
}

.spark[data-health="degraded"] circle {
  fill: var(--degraded);
}

.service-name {
  margin: 0;
  font-weight: 600;
  font-size: 16px;
}

.service-desc {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-soft);
}

.pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--unknown-bg);
  color: var(--text-soft);
}
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.pill[data-health="up"] {
  background: var(--up-bg);
  color: var(--brand-deep);
}
.pill[data-health="up"]::before {
  background: var(--up);
}
.pill[data-health="degraded"] {
  background: var(--degraded-bg);
  color: var(--text);
}
.pill[data-health="degraded"]::before {
  background: var(--degraded);
}
.pill[data-health="down"] {
  background: var(--down-bg);
  color: var(--text);
}
.pill[data-health="down"]::before {
  background: var(--down);
}

.bars {
  display: grid;
  grid-template-columns: repeat(90, minmax(0, 1fr));
  gap: 2px;
  height: 34px;
  margin: 14px 0 6px;
}

.bar {
  border: 0;
  padding: 0;
  border-radius: 3px;
  background: var(--nodata);
  cursor: default;
  transition: transform 0.12s ease;
}
.bar:hover,
.bar:focus-visible {
  transform: scaleY(1.12);
  outline: none;
}
.bar:focus-visible {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-deep);
}
.bar[data-health="up"] {
  background: var(--up);
}
.bar[data-health="degraded"] {
  background: var(--degraded);
}
.bar[data-health="down"] {
  background: var(--down);
}

.service-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  font-size: 12px;
  color: var(--text-faint);
}

.service-foot strong {
  color: var(--text-soft);
  font-weight: 600;
}

/* No celular: 30 dias, para as barras continuarem tocáveis. */
@media (max-width: 640px) {
  .bars {
    grid-template-columns: repeat(30, minmax(0, 1fr));
    gap: 3px;
  }
  .bar:nth-child(-n + 60) {
    display: none;
  }
  .card {
    padding: 16px;
  }
  .summary {
    gap: 8px;
  }
  .stat {
    padding: 12px;
  }
  .stat-label {
    font-size: 12px;
  }
  .stat-value {
    font-size: 20px;
  }
  .stat-hint,
  .spark {
    display: none;
  }
  .banner {
    padding: 18px;
  }
  .link {
    display: none;
  }
}

/* ---- Incidentes ---------------------------------------------------------------------------------------------- */

.incident {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border-soft);
}

.incident:first-child {
  border-top: 0;
}

.incident-mark {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--degraded);
}

.incident[data-severity="down"] .incident-mark {
  background: var(--down);
}

.incident[data-open="false"] .incident-mark {
  background: var(--up);
}

.incident-title {
  margin: 0;
  font-weight: 600;
}

.incident-meta {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-soft);
}

.empty {
  padding: 12px 0 4px;
  color: var(--text-soft);
  font-size: 14px;
}

.incidents .empty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.incidents .empty::before {
  content: "";
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 4px var(--up-bg);
}

/* ---- Rodapé e dica ------------------------------------------------------------------------------------------- */

.footer {
  padding-top: 4px;
  padding-bottom: 40px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.footer p {
  margin: 4px 0;
}

.tooltip {
  position: fixed;
  z-index: 10;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.tooltip strong {
  display: block;
  font-size: 13px;
}
