@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&family=Open+Sans:wght@300;400;500;600;700&display=swap");

/*
 * AIAH front-end — ParentSense design system.
 *
 * Layered on top of Bootstrap 5.3 using its native color modes
 * (`data-bs-theme="light|dark"`). Palette + type follow the ParentSense brand:
 * slate-green (#647775) and mint (#9FCFCA) accents on soft, warm neutrals, with
 * Lato for headings/brand and Open Sans for body copy.
 */

/* ── Typography ─────────────────────────────────────────────────────────── */

:root {
  --ui-font: "Open Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-font-head: "Lato", "Open Sans", system-ui, sans-serif;
  --ui-radius: 12px;
  --ui-radius-sm: 9px;
  --ui-transition: 160ms ease;
}

/* ── Light mode: soft warm neutrals, slate-green ink, mint accent ────────── */

[data-bs-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-muted: #f3f6f5;
  --ink: #32373c;
  --ink-soft: #5f6f6d;
  --ink-faint: #9aa5a3;
  --line: #e8eae9;
  --line-strong: #d9d8d6;
  --brand: #647775;
  --brand-strong: #515f5d;
  --accent: #9fcfca;
  --accent-soft: #e7f2f0;
  --invert-bg: #647775;
  --invert-ink: #ffffff;
  --ring: rgba(100, 119, 117, 0.20);
  --shadow: 0 1px 2px rgba(50, 55, 60, 0.04), 0 10px 30px rgba(50, 55, 60, 0.08);
}

/* ── Dark mode: deep slate surfaces, mint accent ─────────────────────────── */

[data-bs-theme="dark"] {
  --bg: #181d1c;
  --bg-elev: #202624;
  --bg-muted: #272e2c;
  --ink: #eef1f0;
  --ink-soft: #aebbb8;
  --ink-faint: #7c8a87;
  --line: #2e3634;
  --line-strong: #3b4341;
  --brand: #9fcfca;
  --brand-strong: #b4dcd7;
  --accent: #9fcfca;
  --accent-soft: #243230;
  --invert-bg: #9fcfca;
  --invert-ink: #16201e;
  --ring: rgba(159, 207, 202, 0.30);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.55);
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--ui-font);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.006em;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--ui-font-head);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.display-hero {
  font-weight: 300;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.text-soft { color: var(--ink-soft) !important; }
.text-faint { color: var(--ink-faint) !important; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--ink-faint);
}

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  transition: border-color var(--ui-transition), opacity var(--ui-transition);
}

a:hover {
  color: var(--brand);
  border-color: var(--brand);
}

a.plain,
a.plain:hover {
  border-bottom: 0;
}

/* ── Brand mark ─────────────────────────────────────────────────────────── */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  border-bottom: 0;
}

.brand .brand-dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--invert-bg);
  color: var(--invert-ink);
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
}

/* ── ParentSense logo lockup ────────────────────────────────────────────── */

.brand-logo {
  display: inline-flex;
  align-items: center;
  border-bottom: 0;
  line-height: 0;
}

.brand-logo:hover { border-bottom: 0; }

.brand-logo img {
  height: 30px;
  width: auto;
  display: block;
}

.brand-logo.brand-logo-sm img { height: 26px; }
.brand-logo.brand-logo-lg img { height: 40px; }

/* Theme-aware: show the light-on-dark wordmark only in dark mode. */
.brand-logo .logo-dark { display: none; }
[data-bs-theme="dark"] .brand-logo .logo-light { display: none; }
[data-bs-theme="dark"] .brand-logo .logo-dark { display: block; }

/* ── Surfaces / cards ───────────────────────────────────────────────────── */

.surface {
  background-color: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--ui-radius);
}

.surface-pad { padding: 1.5rem; }

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--ui-radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  font-size: 0.88rem;
  color: var(--ink);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius-sm);
  padding: 0.6rem 0.8rem;
  transition: border-color var(--ui-transition), box-shadow var(--ui-transition);
}

.form-control::placeholder { color: var(--ink-faint); }

.form-control:focus,
.form-select:focus {
  color: var(--ink);
  background-color: var(--bg);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}

/* ── Input with trailing affix (e.g. show/hide password) ────────────────── */

.input-affix { position: relative; }

.input-affix > .form-control { padding-right: 2.75rem; }

.input-affix-btn {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  border-radius: 7px;
  cursor: pointer;
  transition: color var(--ui-transition), background-color var(--ui-transition);
}

.input-affix-btn:hover { color: var(--ink); background-color: var(--bg-muted); }
.input-affix-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); color: var(--ink); }
.input-affix-btn svg { width: 17px; height: 17px; }

.input-affix-btn .icon-eye-off { display: none; }
.input-affix-btn[aria-pressed="true"] .icon-eye { display: none; }
.input-affix-btn[aria-pressed="true"] .icon-eye-off { display: block; }

/* ── Buttons: pure black/white inversion ────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  line-height: 1.1;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  border-radius: var(--ui-radius-sm);
  padding: 0.6rem 1rem;
  transition: transform var(--ui-transition), opacity var(--ui-transition),
    background-color var(--ui-transition), border-color var(--ui-transition);
}

/* Leading icons inside buttons are constrained so they sit beside the label
   (an unsized SVG renders huge and lands on top of the text). */
.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn:active { transform: translateY(1px); }

.btn-ink {
  background-color: var(--invert-bg);
  color: var(--invert-ink);
  border: 1px solid var(--invert-bg);
}

.btn-ink:hover {
  background-color: var(--invert-bg);
  color: var(--invert-ink);
  opacity: 0.88;
}

.btn-ink:disabled {
  opacity: 0.45;
}

.btn-ghost {
  background-color: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-ghost:hover {
  background-color: var(--bg-muted);
  color: var(--ink);
  border-color: var(--ink);
}

.btn-link-soft {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 0;
  font-size: 0.82rem;
}

.btn-link-soft:hover { color: var(--ink); }

/* ── Theme toggle ───────────────────────────────────────────────────────── */

.theme-toggle {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background-color: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color var(--ui-transition), border-color var(--ui-transition),
    background-color var(--ui-transition);
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
[data-bs-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-bs-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Alerts (inline form feedback) ──────────────────────────────────────── */

.notice {
  display: none;
  font-size: 0.82rem;
  border-radius: var(--ui-radius-sm);
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  background-color: var(--bg-muted);
  color: var(--ink);
}

.notice.is-error {
  border-color: var(--ink);
}

.notice.show { display: block; }

/* ── Backend connection status (login page) ─────────────────────────────── */

.conn-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.conn-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.conn-status[data-state="checking"] .conn-dot {
  background: #d1a54a;
  animation: conn-pulse 1s ease-in-out infinite;
}
.conn-status[data-state="ok"] .conn-dot { background: #3fae6b; }
.conn-status[data-state="warn"] .conn-dot { background: #d1a54a; }
.conn-status[data-state="down"] .conn-dot { background: #d05a5a; }

@keyframes conn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.conn-target {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

/* ── App chrome (dashboard) ─────────────────────────────────────────────── */

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.app-topbar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}

/* ── Stat cards ─────────────────────────────────────────────────────────── */

.stat {
  padding: 1.25rem 1.35rem;
}

.stat .stat-label {
  font-size: 0.74rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.stat .stat-value {
  font-size: 1.9rem;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-top: 0.35rem;
}

.stat .stat-delta {
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.stat .stat-delta.is-up::before { content: "▲"; font-size: 0.6rem; }
.stat .stat-delta.is-down::before { content: "▼"; font-size: 0.6rem; }

/* ── Charts (hand-drawn SVG, monochrome) ────────────────────────────────── */

.chart-svg { width: 100%; height: auto; display: block; }

.chart-svg .axis { stroke: var(--line); stroke-width: 1; }
.chart-svg .gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.chart-svg .line { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart-svg .area { fill: var(--ink); opacity: 0.06; }
.chart-svg .dot { fill: var(--bg-elev); stroke: var(--ink); stroke-width: 2; }
.chart-svg .bar { fill: var(--ink); }
.chart-svg .bar-track { fill: var(--line); }
.chart-svg .label { fill: var(--ink-faint); font-size: 10px; }

/* ── Simple list rows ───────────────────────────────────────────────────── */

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}

.row-item:last-child { border-bottom: 0; }

.pill {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}

/* ── Loading veil ───────────────────────────────────────────────────────── */

.veil {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: var(--bg);
  z-index: 50;
  transition: opacity 200ms ease;
}

.veil.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--ink);
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: inline-block;
  vertical-align: -2px;
  animation: spin 600ms linear infinite;
}
