/* ==========================================================================
   API Monitor — design tokens

   Signature: chaque API surveillée est représentée par un tracé de pouls
   (moniteur cardiaque) plutôt qu'un badge générique. Battement régulier =
   actif, ligne plate = en panne. Le "health check" est montré, pas décrit.
   ========================================================================== */

:root {
  --ink: #10151c;
  --surface: #181f28;
  --surface-raised: #1f2830;
  --line: #2a3542;
  --paper: #e8edf2;
  --muted: #7c8aa0;
  --signal: #f0a202;
  --signal-dim: #b97f0a;
  --pulse-up: #2dd4a7;
  --pulse-down: #ff5c5c;
  --danger: #ff5c5c;

  --font-display: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --radius: 6px;
  --radius-lg: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-display);
  margin: 0;
  color: var(--paper);
  background: var(--ink);
  background-image: radial-gradient(circle at 15% 0%, rgba(240, 162, 2, 0.06), transparent 45%);
}

a {
  color: var(--signal);
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ---------- layout shell ---------- */

.site-header,
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

main {
  padding: 2.5rem 2rem 4rem;
  max-width: 980px;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--paper);
}

.wordmark__bracket {
  color: var(--signal);
}

.wordmark__dot {
  color: var(--muted);
  margin: 0 0.15em;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.3rem;
  margin-top: 2.5rem;
}

h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 2rem;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- fleet summary (header live status) ---------- */

.fleet-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.fleet-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.fleet-dot--up {
  background: var(--pulse-up);
  box-shadow: 0 0 0 3px rgba(45, 212, 167, 0.18);
}

.fleet-dot--down {
  background: var(--pulse-down);
  box-shadow: 0 0 0 3px rgba(255, 92, 92, 0.18);
  animation: fleet-alert 1.4s ease-in-out infinite;
}

.fleet-dot--pending {
  background: var(--muted);
}

@keyframes fleet-alert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
}

.header-actions a {
  color: var(--muted);
  text-decoration: none;
}

.header-actions a:hover {
  color: var(--paper);
}

/* ---------- buttons ---------- */

button {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.btn,
a.button,
.card-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  background: var(--signal);
  color: var(--ink);
  font-weight: 600;
  transition: background 0.15s ease;
}

.btn:hover,
a.button:hover,
.card-form button[type="submit"]:hover {
  background: #ffb733;
}

header button[type="submit"] {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
  padding: 0.45rem 0.9rem;
}

header button[type="submit"]:hover {
  color: var(--paper);
  border-color: var(--muted);
}

.btn-quiet {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: var(--radius);
}

.btn-quiet:hover {
  color: var(--paper);
  background: var(--surface-raised);
}

.btn-quiet--danger:hover {
  color: var(--pulse-down);
}

.secondary {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}

.secondary:hover {
  border-color: var(--muted);
  background: var(--surface-raised);
}

/* ---------- toolbar ---------- */

.toolbar {
  margin-bottom: 1.5rem;
}

/* ---------- pulse list (dashboard) ---------- */

.pulse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pulse-row {
  display: grid;
  grid-template-columns: 96px 1fr auto auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
}

.pulse-row__signal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.pulse-row__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.pulse-row__name {
  color: var(--paper);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.pulse-row__name:hover {
  color: var(--signal);
}

.pulse-row__url {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 460px;
}

.pulse-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pulse-row__latency {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
  min-width: 56px;
}

.pulse-row__actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  letter-spacing: 0.02em;
}

.tag--on {
  color: var(--pulse-up);
  border-color: rgba(45, 212, 167, 0.35);
}

.tag--off {
  color: var(--muted);
}

/* ---------- pulse trace component ---------- */

.pulse {
  width: 84px;
  height: 26px;
  flex-shrink: 0;
}

.pulse svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pulse__line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke: var(--muted);
}

.pulse--up .pulse__line {
  stroke: var(--pulse-up);
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  animation: pulse-run 1.6s linear infinite;
}

.pulse--down .pulse__line {
  stroke: var(--pulse-down);
}

.pulse--pending .pulse__line {
  opacity: 0.4;
}

@keyframes pulse-run {
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse--up .pulse__line {
    animation: none;
    stroke-dashoffset: 0;
  }
  .fleet-dot--down {
    animation: none;
  }
}

.pulse-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pulse-label--up { color: var(--pulse-up); }
.pulse-label--down { color: var(--pulse-down); }
.pulse-label--pending { color: var(--muted); }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
}

.empty-state a {
  color: var(--signal);
}

/* ---------- ledger tables (history) ---------- */

.apis-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.apis-table th,
.apis-table td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.apis-table th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  background: var(--surface-raised);
}

.apis-table td.mono,
.apis-table td {
  font-family: var(--font-mono);
  color: var(--paper);
  font-size: 0.82rem;
}

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

.apis-table .actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-family: var(--font-display);
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-display);
}

.link-btn:hover {
  color: var(--pulse-down);
}

/* ---------- status badges (history log) ---------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.badge-up {
  background: rgba(45, 212, 167, 0.12);
  color: var(--pulse-up);
}

.badge-down {
  background: rgba(255, 92, 92, 0.12);
  color: var(--pulse-down);
}

.badge-unknown {
  background: rgba(124, 138, 160, 0.12);
  color: var(--muted);
}

/* ---------- forms ---------- */

.card-form,
.login-form {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 420px;
}

.card-form label,
.login-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: var(--muted);
  gap: 0.35rem;
}

.card-form label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--paper);
}

.card-form input,
.card-form select,
.login-form input {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
}

.card-form input:focus,
.card-form select:focus,
.login-form input:focus {
  border-color: var(--signal);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mail-status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  min-height: 1.2em;
}

.mail-status.success {
  color: var(--pulse-up);
}

.mail-status.error {
  color: var(--pulse-down);
}

.error {
  color: var(--pulse-down);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* ---------- login page ---------- */

.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 2rem;
  padding: 1.5rem;
}

.login-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.login-wordmark .wordmark {
  font-size: 1.4rem;
}

.login-ambient {
  width: 220px;
  height: 40px;
}

.login-ambient .pulse__line {
  stroke: var(--signal-dim);
}

.login-form {
  width: 300px;
}

.login-form h1 {
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

/* ---------- history page ---------- */

.history-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  main {
    padding: 1.5rem 1rem 3rem;
  }

  .pulse-row {
    grid-template-columns: 64px 1fr;
    grid-template-areas:
      "signal main"
      "latency actions";
    row-gap: 0.6rem;
  }

  .pulse-row__signal { grid-area: signal; }
  .pulse-row__main { grid-area: main; }
  .pulse-row__latency {
    grid-area: latency;
    text-align: left;
  }
  .pulse-row__actions { grid-area: actions; justify-self: end; }

  .pulse { width: 56px; }

  .pulse-row__url { max-width: 100%; }

  .site-header, header {
    padding: 1rem 1.25rem;
  }

  .apis-table {
    display: block;
    overflow-x: auto;
  }
}
