/* ==========================================================================
   GN Assist — Shared Design System
   Used by every tool on the hub. Keep this the single source of visual
   truth: brand tokens, layout shell, and reusable components.
   ========================================================================== */

:root {
  --brand-primary: #0b3b5c;
  --brand-primary-dark: #082a42;
  --brand-primary-light: #e5eef5;
  --brand-accent: #2a7de1;
  --brand-accent-light: #eaf2fd;

  --success: #1e7b4c;
  --success-bg: #e8f5ee;
  --warning: #b5720f;
  --warning-bg: #fdf3e2;
  --danger: #c62828;
  --danger-bg: #fdeceb;
  --info: #2a7de1;
  --info-bg: #eaf2fd;

  --bg: #f4f7fb;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd7e5;
  --text: #16283a;
  --text-muted: #5a6b7d;
  --text-faint: #8093a6;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 10px 30px rgba(10, 30, 50, 0.08), 0 2px 8px rgba(10, 30, 50, 0.04);
  --shadow-hover: 0 16px 40px rgba(10, 30, 50, 0.12);

  --font: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  --transition: 0.18s ease;
}

/* ---------- Reset & base ---------- */
.hub-reset, .hub-reset *, .hub-reset *::before, .hub-reset *::after {
  box-sizing: border-box;
}

body.hub-body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

/* ---------- Top nav ---------- */
.hub-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
  flex-wrap: wrap;
}

.hub-nav a {
  color: #fff;
  text-decoration: none;
}

.hub-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.2px;
}

.hub-nav-brand .mark {
  font-size: 1.3rem;
}

/* Tool links sit on their own full-width row below the brand and actions, as a
   single line that scrolls sideways when it doesn't fit, so the nav stays short
   on phones however many tools are added. */
.hub-nav-links {
  order: 3;
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.hub-nav-links::-webkit-scrollbar {
  display: none;
}

.hub-nav-links a {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  transition: background var(--transition);
  white-space: nowrap;
}

.hub-nav-links a:hover {
  background: rgba(255, 255, 255, 0.22);
}

.hub-nav-links a.current {
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-primary-dark);
}

.hub-nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
}

.hub-nav-actions a {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  transition: background var(--transition);
}

.hub-nav-actions a:hover {
  background: rgba(255, 255, 255, 0.22);
}

.hub-nav-actions a.donate {
  background: #fff;
  color: var(--brand-primary-dark);
}

.hub-nav-actions a.donate:hover {
  background: var(--brand-primary-light);
}

/* Language menu (built by assets/i18n.js), styled like the nav pills */
.hub-lang {
  position: relative;
}

.hub-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.hub-lang-btn:hover,
.hub-lang-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.22);
}

.hub-lang-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.hub-lang svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hub-lang-btn svg:last-child {
  width: 12px;
  height: 12px;
  opacity: 0.75;
  transition: transform var(--transition);
}

.hub-lang-btn[aria-expanded="true"] svg:last-child {
  transform: rotate(180deg);
}

.hub-lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 160px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-hover);
}

.hub-lang-menu[hidden] {
  display: none;
}

.hub-lang-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  border: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-primary-dark);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.hub-lang-menu button:hover,
.hub-lang-menu button:focus-visible {
  outline: none;
  background: var(--brand-primary-light);
}

.hub-lang-menu button[aria-checked="true"] {
  font-weight: 700;
  color: var(--brand-accent);
}

.hub-lang-menu button svg {
  visibility: hidden;
  stroke-width: 2.2;
}

.hub-lang-menu button[aria-checked="true"] svg {
  visibility: visible;
}

/* ---------- Page shell ---------- */
.hub-main {
  padding: 1.75rem 1.25rem 2.5rem;
  display: flex;
  justify-content: center;
}

.hub-page-title {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto 1.1rem;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.hub-page-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-primary-dark);
  letter-spacing: -0.3px;
  margin: 0;
}

.hub-page-title .hub-badge {
  background: var(--brand-primary-light);
  color: var(--brand-primary-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
}

.hub-subtitle {
  max-width: 1200px;
  margin: 0 auto 1.4rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  border-left: 4px solid var(--brand-accent);
  padding-left: 0.9rem;
  line-height: 1.5;
}

/* ---------- Card ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 1.4rem 1.5rem;
  transition: box-shadow var(--transition);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-primary-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}

.section-title {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 1.1rem 0 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

/* ---------- Form elements ---------- */
.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 0.3rem;
}

.field-label .unit-hint,
.field-label .text-muted-inline {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  font-size: 0.7rem;
}

input.field-control,
select.field-control,
textarea.field-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: #fff;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input.field-control:focus,
select.field-control:focus,
textarea.field-control:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(42, 125, 225, 0.15);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1.5px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn:hover { background: var(--brand-accent-light); border-color: var(--brand-accent); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(11, 59, 92, 0.25);
}
.btn-primary:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); }

.btn-secondary {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-light);
  color: var(--brand-primary-dark);
}
.btn-secondary:hover { background: #d8e6f2; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #175f3b; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #9e1f1f; }

.btn-block { width: 100%; }

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Badges / tags / pills ---------- */
.badge, .tag, .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-neutral, .pill { background: var(--border); color: var(--text-muted); text-transform: none; font-weight: 600; }
.badge-success, .tag-success { background: var(--success-bg); color: var(--success); }
.badge-warning, .tag-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger, .tag-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info, .tag-info { background: var(--info-bg); color: var(--info); }

/* ---------- Alerts / callout boxes ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 4px solid var(--border-strong);
  background: var(--bg);
  margin: 0.6rem 0;
}

.alert-info { border-left-color: var(--info); background: var(--info-bg); color: #163a5c; }
.alert-success { border-left-color: var(--success); background: var(--success-bg); color: #124a2f; }
.alert-warning { border-left-color: var(--warning); background: var(--warning-bg); color: #6b4a09; }
.alert-danger { border-left-color: var(--danger); background: var(--danger-bg); color: #7a1717; }

/* ---------- Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  background: var(--brand-primary);
  color: #fff;
  padding: 0.6rem 0.7rem;
  text-align: left;
  font-weight: 600;
}

.data-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.data-table tr:nth-child(even) td { background: var(--bg); }
.data-table tr:hover td { background: var(--brand-accent-light); }

/* ---------- Footer / disclaimer ---------- */
.hub-footer {
  max-width: 1200px;
  margin: 1.75rem auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  line-height: 1.6;
}

.hub-footer strong { color: var(--text-muted); }

/* Copyright line at the very bottom of every page */
.hub-copyright {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-faint);
  padding: 0 1.25rem 1.5rem;
}

/* ---------- Utility ---------- */
.hub-text-muted { color: var(--text-muted); }
.hub-flex { display: flex; align-items: center; gap: 0.5rem; }
.hub-flex-wrap { flex-wrap: wrap; }

/* ---------- Lab unit toggle (US / SI) ----------
   One look for every tool's unit switch, taken from the ADPKD toolkit.
   Tools mark the selected button with .active-unit or .active. */
.unit-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

/* Spelled out so a tool's own .btn styles can't change the toggle's look. */
.unit-toggle-row .btn {
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: none;
  transform: none;
}

.unit-toggle-row .btn:hover {
  background: var(--brand-accent-light);
  border-color: var(--brand-accent);
}

.unit-toggle-row .btn.active-unit,
.unit-toggle-row .btn.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.unit-toggle-row .unit-toggle-note {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.7rem;
}

/* ---------- Uniform tool layout ----------
   Tools arrive with their own stylesheets. These rules override them (via the
   extra `body.hub-body` specificity) so every tool shares the same content
   width, page-title size and form-control font. */
body.hub-body .hub-main > * {
  width: 100%;
  max-width: 1200px;
}

body.hub-body .hub-main h1 {
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

body.hub-body .hub-main .hub-page-title h1 {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-primary-dark);
}

body.hub-body .hub-page-title .hub-title-action {
  flex: 0 0 auto;
  min-width: 0;
  margin-left: auto;
  align-self: center;
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
}

body.hub-body .hub-main input,
body.hub-body .hub-main select,
body.hub-body .hub-main textarea,
body.hub-body .hub-main button {
  font-family: inherit;
}

/* Phones: let long (e.g. French) words and labels wrap instead of widening the page */
@media (max-width: 600px) {
  body.hub-body .hub-main {
    overflow-wrap: break-word;
  }
  body.hub-body .hub-main button {
    white-space: normal;
    min-width: 0;
    max-width: 100%;
  }
  body.hub-body .hub-main select {
    max-width: 100%;
  }
  body.hub-body .hub-main .card {
    min-width: 0;
    max-width: 100%;
  }
}

/* ---------- Print ---------- */
@media print {
  .hub-nav, .no-print, button { display: none !important; }
  body.hub-body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .hub-footer { display: none; }
}

/* ---------- Sign-out button in the nav (a form, so it posts to /api/logout) ---------- */
.hub-signout-form {
  display: contents;
}

.hub-nav-actions .hub-signout {
  padding: 0.4rem 0.85rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition);
}

.hub-nav-actions .hub-signout:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ---------- Sign-in / create-account pages ---------- */
body.hub-body .hub-main > .auth-wrap {
  max-width: 440px;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-card .field-control {
  margin-bottom: 0.65rem;
}

.auth-card .btn-block {
  margin-top: 0.4rem;
}

.auth-error {
  margin: 0.2rem 0 0.4rem;
}

.auth-card[hidden],
.auth-error[hidden] {
  display: none;
}

.auth-switch {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-switch a {
  color: var(--brand-accent);
  font-weight: 600;
}

/* Notice after a redirect from a tool this account can't open (assets/session.js) */
.hub-denied {
  margin: 0 auto 1rem;
  max-width: 1100px;
}
