/* Status page — visual estilo "Statuspage" (Atlassian): fundo claro, banner de
   status geral, e por componente um gráfico de barras de uptime dos últimos 90
   dias. Cores de status são variáveis; o fundo (--sp-bg) e o logo são
   customizáveis por tenant (vêm no artifact / config). */

:root {
  --sp-bg: #faf8f3;              /* fundo da página (customizável por tenant) */
  --sp-fg: #1b1b18;             /* texto principal */
  --sp-muted: #6b6b63;          /* texto secundário */
  --sp-card: #ffffff;           /* fundo dos cards */
  --sp-border: #e6e3da;         /* bordas/hairlines */
  --sp-radius: 8px;
  --sp-maxw: 880px;

  /* Paleta de status (barras + rótulos + banner). */
  --st-ok: #3aa655;
  --st-degraded: #e0b000;
  --st-partial: #e08a1e;
  --st-major: #d64b3f;
  --st-maint: #3b82c4;
  --st-empty: #e4e1d8;          /* dia sem dado (não usado: dias limpos = ok) */
}

* { box-sizing: border-box; }

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

.wrap {
  width: 100%;
  max-width: var(--sp-maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header ------------------------------------------------------------------- */
.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 40px;
  padding-bottom: 28px;
}
.sp-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sp-logo { height: 34px; width: auto; display: block; }
.sp-brand-text {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-subscribe {
  flex-shrink: 0;
  border: 0;
  background: #16160f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 18px;
  border-radius: 6px;
  cursor: pointer;
}
.sp-subscribe:hover { background: #000; }

/* Banner de status geral --------------------------------------------------- */
.sp-banner {
  border-radius: var(--sp-radius);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  padding: 22px 24px;
  margin: 12px 0 40px;
  background: var(--st-ok);
}
.sp-banner.b-degraded, .sp-banner.b-maint { background: var(--st-degraded); }
.sp-banner.b-partial { background: var(--st-partial); }
.sp-banner.b-major { background: var(--st-major); }

/* Seções (incidentes / manutenções) --------------------------------------- */
.sp-section { margin-bottom: 32px; }
.sp-section:empty { display: none; }
.sp-section-title { font-size: 14px; font-weight: 700; color: var(--sp-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 10px; }
.sp-note {
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.sp-note-title { font-weight: 600; }
.sp-note-meta { color: var(--sp-muted); font-size: 13px; margin-top: 2px; }

/* Cabeçalho da lista de uptime -------------------------------------------- */
.sp-uptime-head {
  text-align: right;
  color: var(--sp-muted);
  font-size: 13px;
  margin-bottom: 10px;
}

/* Componentes -------------------------------------------------------------- */
.sp-group-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--sp-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 22px 0 8px;
}
.sp-comp {
  border-top: 1px solid var(--sp-border);
  padding: 18px 2px 20px;
}
.sp-comp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sp-comp-name { font-weight: 600; }
.sp-comp-status { font-size: 14px; font-weight: 500; }

/* Barras de uptime (90 dias) ---------------------------------------------- */
.sp-bars {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 34px;
}
.sp-bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--st-empty);
  transition: opacity .12s;
}
.sp-bar:hover { opacity: 0.65; }

.sp-comp-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--sp-muted);
  font-size: 12px;
}
.sp-comp-foot .sp-rule { flex: 1 1 auto; height: 1px; background: var(--sp-border); }
.sp-comp-foot .sp-uptime { flex-shrink: 0; }

/* Incidente aninhado no componente */
.sp-comp-incident {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--sp-muted);
}
.sp-comp-incident .sp-inc-title { color: var(--sp-fg); font-weight: 500; }

/* Cores por status (rótulos + barras) ------------------------------------- */
.status-ok { color: var(--st-ok); }
.status-degraded { color: var(--st-degraded); }
.status-partial { color: var(--st-partial); }
.status-major { color: var(--st-major); }
.status-maint { color: var(--st-maint); }
.sp-bar.status-ok { background: var(--st-ok); }
.sp-bar.status-degraded { background: var(--st-degraded); }
.sp-bar.status-partial { background: var(--st-partial); }
.sp-bar.status-major { background: var(--st-major); }
.sp-bar.status-maint { background: var(--st-maint); }

/* Rodapé / erro ------------------------------------------------------------ */
.sp-footer { color: var(--sp-muted); font-size: 12px; padding: 40px 20px 60px; text-align: center; }
.sp-error { color: var(--st-major); text-align: center; padding: 24px; }

/* Painel de inscrição ------------------------------------------------------ */
.sp-subscribe-panel {
  margin-bottom: 24px;
  padding: 14px 16px;
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
}
.sp-sub-form { display: flex; gap: 8px; }
.sp-sub-input {
  flex: 1 1 auto; min-width: 0; padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--sp-border); border-radius: 6px;
  background: var(--sp-bg); color: var(--sp-fg);
}
.sp-sub-submit {
  flex-shrink: 0; border: 0; background: #16160f; color: #fff;
  font-size: 13px; font-weight: 600; padding: 9px 18px; border-radius: 6px; cursor: pointer;
}
.sp-sub-submit:hover { background: #000; }
.sp-sub-msg { margin: 10px 0 0; font-size: 13px; }
.sp-sub-msg.ok { color: var(--st-ok); }
.sp-sub-msg.err { color: var(--st-major); }

/* Cards de incidente ativo (topo) ----------------------------------------- */
.sp-active-incidents:empty { display: none; }
.sp-incident-card {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--sp-card);
}
.sp-incident-head { padding: 14px 20px; background: var(--st-major); color: #fff; }
.sp-incident-head.b-degraded, .sp-incident-head.b-maint { background: var(--st-degraded); }
.sp-incident-head.b-partial { background: var(--st-partial); }
.sp-incident-head.b-major { background: var(--st-major); }
.sp-incident-title { color: #fff; font-weight: 600; font-size: 16px; text-decoration: none; }
.sp-incident-title:hover { text-decoration: underline; }
.sp-incident-body { padding: 4px 20px 8px; }
.sp-update { padding: 12px 0; border-top: 1px solid var(--sp-border); }
.sp-update:first-child { border-top: 0; }
.sp-update-line { font-size: 14px; line-height: 1.55; }
.sp-update-time { color: var(--sp-muted); font-size: 12px; margin-top: 4px; }

/* Detalhe do incidente (Incident Report) ---------------------------------- */
#detail { padding-top: 8px; }
.sp-back { display: inline-block; margin: 4px 0 24px; color: var(--sp-muted); text-decoration: none; font-size: 13px; }
.sp-back:hover { text-decoration: underline; }
.sp-detail-title { text-align: center; font-size: 26px; margin: 8px 0 4px; }
.sp-detail-sub { text-align: center; color: var(--sp-muted); margin-bottom: 28px; }
#detail .sp-incident-body { max-width: 640px; margin: 0 auto; padding: 0; }

/* Histórico "Incidentes anteriores" -------------------------------------- */
.sp-past-head { margin-top: 44px; font-size: 20px; color: var(--sp-fg); text-transform: none; letter-spacing: 0; }
.sp-past-day { font-weight: 600; padding-bottom: 8px; margin: 18px 0 4px; border-bottom: 1px solid var(--sp-border); }
.sp-past-incident { padding: 8px 0 2px; }
.sp-past-title { display: inline-block; font-size: 16px; font-weight: 600; text-decoration: none; margin-bottom: 2px; }
.sp-past-title:hover { text-decoration: underline; }
.sp-past-empty { color: var(--sp-muted); padding: 8px 0 2px; }
#past-incidents .sp-incident-body { padding: 0; }

/* Rodapé do histórico + link p/ a página completa */
.sp-past-foot { display: flex; justify-content: flex-end; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--sp-border); }
.sp-history-link { color: var(--sp-muted); text-decoration: none; font-size: 14px; }
.sp-history-link:hover { color: var(--sp-fg); text-decoration: underline; }

/* Página "Histórico de incidentes" (#/history) ---------------------------- */
#history { padding-top: 8px; }
.sp-history-title { font-size: 26px; margin: 8px 0 20px; }
.sp-history-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 28px; }
.sp-history-arrow {
  border: 1px solid var(--sp-border); background: var(--sp-card); color: var(--sp-fg);
  width: 34px; height: 34px; border-radius: 6px; font-size: 18px; line-height: 1; cursor: pointer;
}
.sp-history-arrow:hover:not(:disabled) { background: var(--sp-bg); }
.sp-history-arrow:disabled { opacity: 0.4; cursor: default; }
.sp-history-range { min-width: 240px; text-align: center; font-weight: 600; }
.sp-history-month { font-size: 22px; font-weight: 600; margin: 32px 0 4px; padding-bottom: 10px; border-bottom: 1px solid var(--sp-border); }
.sp-history-incident { padding: 16px 0 4px; }
.sp-history-inc-title { display: inline-block; font-size: 16px; font-weight: 600; text-decoration: none; margin-bottom: 4px; }
.sp-history-inc-title:hover { text-decoration: underline; }
.sp-history-inc-body { font-size: 14px; line-height: 1.55; }
.sp-history-inc-meta { color: var(--sp-muted); font-size: 13px; margin-top: 4px; }
.sp-history-more {
  display: block; width: 100%; margin: 16px 0 4px; padding: 12px;
  border: 1px solid var(--sp-border); background: var(--sp-card); color: var(--sp-muted);
  border-radius: var(--sp-radius); font-size: 14px; cursor: pointer; text-align: center;
}
.sp-history-more:hover { color: var(--sp-fg); background: var(--sp-bg); }

/* Manutenção no histórico (selo + título azul, não clicável) */
.sp-maint-title-wrap { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sp-tag-maint {
  flex-shrink: 0; align-self: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--st-maint); background: color-mix(in srgb, var(--st-maint) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-maint) 40%, transparent);
  padding: 2px 8px; border-radius: 999px;
}

@media (max-width: 560px) {
  .sp-brand-text { font-size: 20px; }
  .sp-banner { font-size: 17px; padding: 18px 18px; }
  .sp-bars { height: 30px; gap: 1px; }
}
