/* ============================================================
   cvcalc.com — Cardiometabolic decision support
   GLP-1 & GIP/GLP-1 Knowledge Base
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Clinical palette: neutral, high-contrast, low saturation.
     Chosen for legibility under hospital lighting + grayscale-print friendliness. */
  --c-bg:         #f7f8fa;
  --c-surface:    #ffffff;
  --c-surface-2:  #eef1f5;
  --c-border:     #d6dbe0;
  --c-border-2:   #c0c6cd;
  --c-text:       #1c2128;
  --c-text-mute:  #57606a;
  --c-text-dim:   #8b929b;

  /* Accents — single hue family, used sparingly */
  --c-accent:        #1f5fa6;   /* deep clinical blue */
  --c-accent-soft:   #e7eff8;
  --c-accent-hover:  #174a85;

  /* Semantics */
  --c-ok:        #2c7a3b;
  --c-ok-soft:   #e6f2ea;
  --c-warn:      #a35d00;
  --c-warn-soft: #fbf0dc;
  --c-danger:    #b3261e;
  --c-danger-soft:#fbe9e7;

  /* Confidence tags */
  --c-conf-label:    #1f5fa6;
  --c-conf-guide:    #5b3fa3;
  --c-conf-offlabel: #a35d00;
  --c-conf-expert:   --c-text-mute;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  /* Typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --max-width: 1240px;
  --header-h: 56px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--c-accent-hover); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--sp-3) 0;
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; color: var(--c-text-mute); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Header ---------- */
.app-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--sp-5);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.brand-mark {
  font-weight: 700;
  font-size: 18px;
  color: var(--c-accent);
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 13px;
  color: var(--c-text-mute);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.mode-switch {
  display: flex;
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: 2px;
  border: 1px solid var(--c-border);
}

.mode-switch button {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-mute);
  transition: background 0.12s, color 0.12s;
}

.mode-switch button.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.lang-toggle {
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text-mute);
  letter-spacing: 0.04em;
}

.lang-toggle:hover { border-color: var(--c-border-2); color: var(--c-text); }

/* ---------- Main layout ---------- */
.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-7);
}

/* ---------- Mode 1: browse ---------- */
.filters-bar {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.filters-label {
  font-size: 12px;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: var(--sp-2);
}

.chip {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--c-text-mute);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.chip:hover { border-color: var(--c-border-2); color: var(--c-text); }

.chip.active {
  background: var(--c-accent);
  color: white;
  border-color: var(--c-accent);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.card:hover {
  border-color: var(--c-accent);
  box-shadow: 0 2px 8px rgba(31, 95, 166, 0.08);
}

.card-brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 2px;
}

.card-molecule {
  font-size: 12px;
  color: var(--c-text-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-3);
}

.card-indications {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-indication {
  font-size: 13px;
  color: var(--c-text);
  padding: var(--sp-1) 0;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}

.card-indication::before {
  content: "·";
  color: var(--c-text-dim);
  font-weight: bold;
  flex-shrink: 0;
}

/* ---------- Confidence badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-label    { background: var(--c-accent-soft); color: var(--c-conf-label); }
.badge-guide    { background: #efe9f7; color: var(--c-conf-guide); }
.badge-offlabel { background: var(--c-warn-soft); color: var(--c-conf-offlabel); }
.badge-expert   { background: var(--c-surface-2); color: var(--c-text-mute); }

/* ---------- Detail panel (Mode 1 expanded) ---------- */
.detail-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-top: var(--sp-4);
}

.detail-section {
  margin-bottom: var(--sp-5);
}

.detail-section:last-child { margin-bottom: 0; }

.detail-section h4 {
  margin-bottom: var(--sp-2);
}

/* ---------- Mode 2: patient form ---------- */
.form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  max-width: 700px;
  margin-bottom: var(--sp-5);
}

.form-row {
  margin-bottom: var(--sp-4);
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
  margin-bottom: var(--sp-2);
}

.form-row input[type=number],
.form-row input[type=text],
.form-row select {
  width: 100%;
  max-width: 200px;
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--c-surface);
}

.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px var(--c-accent-soft);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-2);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
}

.checkbox-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.btn-primary {
  background: var(--c-accent);
  color: white;
  border: none;
  padding: 9px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
}

.btn-primary:hover { background: var(--c-accent-hover); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  padding: 9px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
}

.btn-secondary:hover { border-color: var(--c-border-2); }

/* ---------- Disclaimer modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 33, 40, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--sp-6);
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.modal h2 { margin-bottom: var(--sp-4); }

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  margin-bottom: var(--sp-5);
}

.modal-body ul {
  padding-left: var(--sp-5);
  margin: var(--sp-3) 0;
}

.modal-body li { margin-bottom: var(--sp-1); }

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
}

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--c-border);
  padding: var(--sp-5);
  background: var(--c-surface);
  margin-top: var(--sp-7);
}

.app-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--c-text-mute);
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.app-footer a { color: var(--c-text-mute); text-decoration: underline; }
.app-footer a:hover { color: var(--c-text); }

/* ---------- Loading / empty states ---------- */
.loading {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--c-text-mute);
  font-size: 14px;
}

.empty-state {
  background: var(--c-surface);
  border: 1px dashed var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  text-align: center;
  color: var(--c-text-mute);
}

.error-banner {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border: 1px solid #f0c4c1;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-header-inner { padding: 0 var(--sp-3); }
  .app-main { padding: var(--sp-4) var(--sp-3); }
  .brand-tagline { display: none; }
  .cards-grid { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
  .mode-switch button { padding: 6px 10px; font-size: 12px; }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.muted { color: var(--c-text-mute); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
