/* Shared styles for home, dashboard, and health pages.
   Self-hosted only — no external CDNs, so everything works offline. */

:root {
  --bg-0: #0b1220;
  --bg-1: #1e3a8a;
  --bg-2: #0f766e;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #0f766e;
  --accent-ink: #115e59;
  --card: #ffffff;
  --card-shadow: 0 14px 40px rgba(8, 15, 35, 0.22);
  --header-bg: rgba(12, 20, 40, 0.72);
  --header-border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
               Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(255, 255, 255, 0.08), transparent 60%),
    radial-gradient(900px 400px at 90% 110%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(135deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Sticky site header (the "defined line" between chrome + content)
   ============================================================ */
header.site {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 20px rgba(0, 0, 0, 0.25);
}

header.site .site-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

header.site .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.2px;
}

header.site .brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  box-shadow: 0 2px 10px rgba(20, 184, 166, 0.45);
  color: #ffffff;
  font-size: 13px;
}

header.site nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

header.site nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}
header.site nav a:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }
header.site nav a.active { color: #ffffff; background: rgba(255, 255, 255, 0.12); }

/* Log out is a POST form, so its button has to pass for a nav link. */
header.site nav .nav-form { display: inline; margin: 0; }
header.site nav .nav-form button {
  color: #cbd5e1;
  background: none;
  border: none;
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
header.site nav .nav-form button:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }

header.site nav .nav-user {
  color: #94a3b8;
  font-size: 13px;
  padding: 7px 4px 7px 12px;
  border-left: 1px solid var(--header-border);
  margin-left: 8px;
}

/* ============================================================
   Layout
   ============================================================ */
main.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 26px 30px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

/* Left-edge accent stripe — subtle visual anchor. */
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #14b8a6, #0ea5e9);
}

.card .eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--ink);
  letter-spacing: -0.2px;
}

.card p {
  line-height: 1.6;
  color: #334155;
  margin: 6px 0;
}

.card + .card { margin-top: 18px; }

/* ============================================================
   Meta grid (key/value pairs)
   ============================================================ */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px 22px;
  margin: 16px 0 4px;
}
.meta-grid .label {
  display: block;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.7px;
  margin-bottom: 4px;
  font-weight: 600;
}
.meta-grid .value {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  font-size: 14px;
  color: var(--ink);
}

/* ============================================================
   Pills + status dots
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pill.mock { background: #e2e8f0; color: #334155; }
.pill.test { background: #fef3c7; color: #92400e; }
.pill.live { background: #dcfce7; color: #166534; }
.pill.ok   { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.err  { background: #fee2e2; color: #991b1b; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}
.dot.ok   { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: pulse 2.2s infinite; }
.dot.warn { background: #f59e0b; }
.dot.err  { background: #ef4444; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ============================================================
   Endpoints list
   ============================================================ */
ul.endpoints {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
ul.endpoints li {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 5px;
  background: #f1f5f9;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}
ul.endpoints .method {
  display: inline-block;
  width: 52px;
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ============================================================
   Button
   ============================================================ */
button.primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.35);
}
button.primary:hover {
  background: var(--accent-ink);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.45);
}
button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================================
   Forms (login)
   ============================================================ */
.card-narrow { max-width: 460px; margin-left: auto; margin-right: auto; }

.stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 18px;
}

.stack label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.hint { font-size: 13px; margin-top: 16px; }

.stack input[type="password"],
.stack input[type="email"] {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.stack input[type="password"]:focus,
.stack input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.stack button.primary { margin-top: 6px; }

.form-error {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 14px;
}

/* ============================================================
   Table
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
th, td {
  text-align: left;
  font-size: 13px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
tbody tr:last-child td { border-bottom: none; }
td.mono {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  color: #0f172a;
}

/* ============================================================
   Components list (used on health page)
   ============================================================ */
ul.components {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
ul.components li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
ul.components .name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}
ul.components .detail {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================
   Hero (the big status block on the health page)
   ============================================================ */
.hero-status {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0 2px;
}
.hero-status .icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #22c55e, #14b8a6);
  color: #ffffff;
  font-size: 28px;
  box-shadow: 0 8px 22px rgba(20, 184, 166, 0.4);
}
.hero-status .icon.warn { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 8px 22px rgba(245, 158, 11, 0.4); }
.hero-status .icon.err  { background: linear-gradient(135deg, #ef4444, #f97316); box-shadow: 0 8px 22px rgba(239, 68, 68, 0.4); }
.hero-status .headline {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.hero-status .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

/* ============================================================
   Footer
   ============================================================ */
footer.site {
  text-align: center;
  color: #cbd5e1;
  font-size: 12px;
  padding: 12px 0 24px;
}

/* ============================================================
   Tiny helpers
   ============================================================ */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

/* ============================================================
   Pay Now — the parent-facing payment pages
   Mobile-first: essentially every visitor arrives from a WhatsApp
   link on a phone, so the base rules ARE the phone rules and the
   only media query widens things for a desktop.
   ============================================================ */
body.pay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.pay-shell {
  width: 100%;
  max-width: 420px;
}

.pay-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  color: #e2e8f0;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.pay-brand .mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.pay-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
  padding: 26px 22px;
  text-align: center;
}

.pay-label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
}

.pay-desc {
  margin: 6px 0 18px;
  font-size: 19px;
  line-height: 1.35;
  font-weight: 600;
  color: var(--ink);
  /* Descriptions come from the WhatsApp app and can be up to 50 characters of
     anything, including an unbroken string. Wrap rather than widen the card. */
  overflow-wrap: anywhere;
}

.pay-amount {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--accent-ink);
}

.pay-note {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.pay-meta {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  text-align: left;
  font-size: 14px;
}
.pay-meta dt { color: var(--muted); }
.pay-meta dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

.pay-form { margin: 22px 0 0; }

.pay-button {
  width: 100%;
  /* 52px clears the ~44px minimum tap target on every phone, with room for a
     thumb that isn't aiming carefully. */
  min-height: 52px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.35);
}
.pay-button:hover { filter: brightness(1.05); }
.pay-button:active { transform: translateY(1px); }
.pay-button.ghost {
  background: none;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.pay-fineprint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.pay-mockflag {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.5;
}
.pay-mock .pay-mockflag { margin: 0 0 18px; }

.pay-ref {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: #cbd5e1;
  overflow-wrap: anywhere;
}
.pay-card .pay-ref { color: var(--muted); }

.pay-foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 11px;
  color: rgba(226, 232, 240, 0.55);
}

/* --- Result page --- */
.pay-result h1 {
  margin: 16px 0 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.pay-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #ffffff;
}
.pay-result.ok  .pay-icon { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.pay-result.bad .pay-icon { background: linear-gradient(135deg, #ef4444, #f97316); }
.pay-reason {
  margin: 14px 0 0;
  font-size: 13px;
  color: #9a3412;
  overflow-wrap: anywhere;
}

/* --- Mock gateway extras --- */
.pay-choices {
  margin: 22px 0 0;
  display: grid;
  gap: 10px;
}

.pay-fields {
  margin: 16px 0 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-size: 12px;
}
.pay-fields summary { cursor: pointer; }
.pay-fields table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  /* A long m4 has to scroll inside this box, not stretch the page sideways. */
  display: block;
  overflow-x: auto;
}
.pay-fields th {
  text-align: left;
  padding: 3px 12px 3px 0;
  font-weight: 600;
  color: #7dd3fc;
  white-space: nowrap;
  vertical-align: top;
}
.pay-fields td {
  padding: 3px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

@media (min-width: 560px) {
  .pay-shell { max-width: 460px; }
  .pay-card { padding: 32px 30px; }
}
