/* Page de statut, style Apple : police du système, listes groupées, barre translucide, clair et sombre automatiques. */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.12);
  --nav-bg: rgba(245, 245, 247, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --green: #34c759;
  --yellow: #ffcc00;
  --orange: #ff9500;
  --red: #ff3b30;
  --blue: #0071e3;
  --purple: #af52de;
  --gray: #aeaeb2;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --separator: rgba(255, 255, 255, 0.1);
    --fill: rgba(118, 118, 128, 0.24);
    --nav-bg: rgba(22, 22, 23, 0.72);
    --shadow: none;
    --green: #30d158;
    --yellow: #ffd60a;
    --orange: #ff9f0a;
    --red: #ff453a;
    --blue: #2997ff;
    --purple: #bf5af2;
    --gray: #636366;
  }
}

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

body {
  font: 100%/1.47 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- Barre du haut, translucide : le contenu défile dessous --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}
.nav-inner {
  max-width: 820px;
  margin: 0 auto;
  height: 52px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
}

.container { max-width: 820px; margin: 0 auto; padding: 0 1.25rem 4rem; }

/* --- État global --- */
.hero { text-align: center; padding: 3.5rem 0 0.5rem; }
.eyebrow {
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}
.global-status { display: flex; flex-direction: column; align-items: center; }
.global-status h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.025em;
  max-width: 16em;
}
.global-status .sub { color: var(--text-2); font-size: 1.0625rem; margin-top: 0.5rem; }
.global-status .dot {
  width: 64px;
  height: 64px;
  margin-bottom: 1.25rem;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}
.global-status .dot.ok::after { content: '✓'; }
/* Point d'exclamation foncé sur le jaune : le blanc y serait illisible */
.global-status .dot.degraded { color: #1d1d1f; }
.global-status .dot.degraded::after,
.global-status .dot.down::after { content: '!'; }
.global-status .dot.checking {
  background: transparent;
  border: 4px solid var(--fill);
  border-top-color: var(--text-2);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Pastilles d'état --- */
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: var(--green); }
.dot.degraded { background: var(--yellow); }
.dot.down { background: var(--red); }
.dot.checking { background: var(--gray); }

/* --- Titres de groupe et listes groupées --- */
.section-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem 0.25rem;
}
.container > section + *, .container > #services + *, .group + .group { margin-top: 2.5rem; }

.services {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.service-card { padding: 1.125rem 1.25rem; }
.service-card + .service-card { border-top: 1px solid var(--separator); }
.service-head { display: flex; align-items: center; gap: 0.75rem; }
.service-info { flex: 1; min-width: 0; }
.service-name { font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.01em; }
.service-name-sub { color: var(--text-2); font-size: 0.8125rem; margin-top: 0.125rem; }
.service-state { flex-shrink: 0; color: var(--text); font-size: 0.9375rem; font-weight: 500; text-align: right; }
.service-state .latency {
  display: block;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.service-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.5rem 0 0 1.375rem;
  color: var(--text-2);
  font-size: 0.8125rem;
}
.service-details strong { color: var(--text); font-weight: 600; }
.service-motd { flex-basis: 100%; white-space: pre-line; }

/* --- Historique sur 90 jours --- */
.uptime-bars { display: flex; gap: 2px; height: 30px; margin-top: 1rem; }
.bar {
  flex: 1;
  min-width: 0;
  border-radius: 3px;
  transform-origin: bottom;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}
.uptime-bars:hover .bar { opacity: 0.55; }
.uptime-bars .bar:hover { opacity: 1; transform: scaleY(1.12); }
.bar.ok { background: var(--green); }
.bar.degraded { background: var(--yellow); }
.bar.outage { background: var(--red); }
.bar.no_data { background: var(--fill); }
.bars-legend {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
  color: var(--text-2);
  font-size: 0.75rem;
}
.bars-legend .uptime-pct { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }

/* --- Incidents --- */
.incident {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.125rem 1.25rem 1.125rem 1.75rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.incident::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 1.125rem;
  bottom: 1.125rem;
  width: 4px;
  border-radius: 2px;
  background: var(--gray);
}
.incident.minor::before { background: var(--blue); }
.incident.major::before { background: var(--orange); }
.incident.critical::before { background: var(--red); }
.incident-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.375rem; }
.incident-title { flex: 1; font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.01em; }
.incident-services { color: var(--text-2); font-size: 0.8125rem; }
.incident-updates { margin-top: 0.875rem; padding-top: 0.375rem; border-top: 1px solid var(--separator); }
.incident-update { display: flex; gap: 1rem; padding: 0.5rem 0; font-size: 0.9375rem; }
.incident-update .time {
  min-width: 7.5rem;
  color: var(--text-2);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.incident-update .text { color: var(--text); }
.update-status { font-weight: 600; }

.badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
}
.badge.investigating { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.badge.identified { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.badge.monitoring { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.badge.resolved { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }

/* --- Boutons : retour au moment de l'appui --- */
.btn {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  border-radius: 999px;
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  transition: transform 100ms ease-out, background-color 150ms ease, opacity 150ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; }
.btn-pill { background: var(--blue); color: #fff; font-size: 0.8125rem; padding: 0.375rem 0.875rem; }
.btn-pill:hover, .btn-primary:hover { opacity: 0.88; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:hover { background: color-mix(in srgb, var(--fill) 70%, var(--text) 8%); }

/* --- Fenêtre de signalement : le fond s'assombrit et se floute, la fenêtre s'avance --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in 200ms ease-out;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px;
  padding: 1.75rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  animation: modal-in 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

.modal h3 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 0.375rem; }
.modal .modal-sub { color: var(--text-2); font-size: 0.9375rem; margin-bottom: 1.5rem; }
.modal label {
  display: block;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 1rem 0 0.375rem;
}
.modal label:first-of-type { margin-top: 0; }
.modal input, .modal select, .modal textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.625rem 0.875rem;
  resize: vertical;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.modal input::placeholder, .modal textarea::placeholder { color: var(--text-2); }
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent);
}
.modal-hint { color: var(--text-2); font-size: 0.75rem; margin-top: 0.375rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
.modal-msg { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.875rem; }
.modal-msg.success { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--text); }
.modal-msg.error { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--text); }

/* --- Pied de page --- */
.footer { margin-top: 3.5rem; text-align: center; color: var(--text-2); font-size: 0.75rem; }
.legal-links { margin-top: 0.5rem; }
.legal-links a, .privacy-notice a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legal-links a:hover { color: var(--text); }

/* --- Téléphone --- */
@media (max-width: 560px) {
  .hero { padding: 2.5rem 0 0.25rem; }
  .global-status .dot { width: 56px; height: 56px; font-size: 1.75rem; }
  .service-card { padding: 1rem; }
  .uptime-bars { gap: 1px; height: 26px; }
  .incident-update { flex-direction: column; gap: 0.125rem; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* --- Accessibilité --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: opacity 150ms ease !important; }
  .btn:active, .uptime-bars .bar:hover { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .nav { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .modal-backdrop { background: rgba(0, 0, 0, 0.6); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
