/* Family Medical Council — M4 styles */

:root {
  --bg: #fafaf8;
  --bg2: #f2f1ed;
  --bg3: #e8e7e3;
  --text: #1a1a18;
  --text2: #6b6a66;
  --text3: #9c9a92;
  --border: #dddcd6;
  --green-bg: #e6f5ec;
  --green-border: #68c98c;
  --green-text: #1a6b35;
  --blue-bg: #e3eefa;
  --blue-border: #6ba3e0;
  --blue-text: #1a4a7a;
  --red-bg: #fce9e7;
  --red-border: #e09080;
  --red-text: #8a3a2a;
  --amber-bg: #fef6e4;
  --amber-border: #f5c842;
  --amber-text: #7a5a00;
  --radius: 6px;
  --radius-lg: 10px;
  --font: -apple-system, 'DM Sans', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ── Nav ─────────────────────────────────────────── */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nav-links { display: flex; gap: 20px; font-size: 13px; }
.nav-logout { color: var(--text2); }

/* ── Main ────────────────────────────────────────── */

.main { max-width: 860px; margin: 0 auto; padding: 32px 24px 80px; }

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ── Lock screen ─────────────────────────────────── */

.lock-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
}

.lock-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.lock-card-wide { max-width: 480px; }

.lock-icon { font-size: 32px; text-align: center; margin-bottom: 12px; }
.lock-title { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.lock-subtitle { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 24px; }
.lock-footer { font-size: 12px; color: var(--text2); text-align: center; margin-top: 16px; }
.lock-form { display: flex; flex-direction: column; gap: 16px; }

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

.field { display: flex; flex-direction: column; gap: 6px; }
.field-divider { border-top: 1px dashed var(--border); margin: 4px 0; }

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.label-hint { font-weight: 400; color: var(--text3); }
.label-inline { font-size: 12px; color: var(--text2); }

.input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.input:focus { border-color: var(--blue-border); }

.textarea { resize: vertical; min-height: 80px; }

.select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

/* ── Buttons ─────────────────────────────────────── */

.btn {
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.1s;
}

.btn:hover { opacity: 0.85; }

.btn-primary {
  background: var(--blue-text);
  color: white;
}

.btn-full { width: 100%; }

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.btn-small:hover { opacity: 0.8; }

/* ── Status badges ───────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  white-space: nowrap;
}
.badge-ongoing  { background: var(--blue-bg);  color: var(--blue-text);  border: 1px solid var(--blue-border); }
.badge-flagged  { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-border); }
.badge-resolved { background: var(--green-bg); color: var(--green-text); border: 1px solid var(--green-border); }
.badge-review   { background: var(--red-bg);   color: var(--red-text);   border: 1px solid var(--red-border); }

/* ── Alerts ──────────────────────────────────────── */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.alert-error { background: var(--red-bg); border-color: var(--red-border); color: var(--red-text); }
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }
.alert-warn { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber-text); }

.alert-redflag {
  background: var(--red-bg);
  border: 2px solid var(--red-border);
  color: var(--red-text);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.redflag-text { font-size: 13px; margin-top: 8px; white-space: pre-wrap; }

.recovery-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}

/* ── Page header ─────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title { font-size: 18px; font-weight: 600; }

/* ── Chat ────────────────────────────────────────── */

.chat-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.profile-selector { display: flex; align-items: center; gap: 8px; }

/* ── Results ─────────────────────────────────────── */

.result-section { margin-top: 8px; }

.result-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.meta-item { font-family: var(--mono); }
.meta-green { color: var(--green-text); }
.meta-muted { color: var(--text3); }

.synthesis-card {
  background: var(--bg);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--blue-text);
  margin-bottom: 10px;
}

.card-body { font-size: 14px; line-height: 1.7; color: var(--text); }

.disclaimer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

/* ── Specialist panels ───────────────────────────── */

.specialist-section { margin-top: 8px; }

.specialist-summary {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  padding: 8px 0;
  list-style: none;
}

.specialist-summary:hover { color: var(--text); }

.specialist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.specialist-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.specialist-error { border-color: var(--red-border); background: var(--red-bg); }

.agent-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.agent-meta { font-weight: 400; color: var(--text3); font-family: var(--mono); }
.agent-tools { font-weight: 400; color: var(--blue-text); font-size: 10px; }
.agent-body { font-size: 12px; line-height: 1.6; color: var(--text); }
.error-text { color: var(--red-text); }

/* ── History ─────────────────────────────────────── */

.history-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; }

.history-sidebar { display: flex; flex-direction: column; gap: 4px; }

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--text2);
  transition: background 0.1s;
}

.log-item:hover { background: var(--bg2); text-decoration: none; color: var(--text); }
.log-item-active { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue-text); }
.log-date { font-family: var(--mono); font-size: 12px; }
.log-enc { font-size: 10px; }

.history-content { min-height: 300px; }

.log-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.empty-state { font-size: 13px; color: var(--text3); padding: 20px 0; }

/* ── Labs ────────────────────────────────────────── */

.lab-item-name {
  font-size: 12px;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.lab-item-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Loading state ───────────────────────────────── */

.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  color: var(--text2);
  font-size: 13px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue-text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.loading-text {
  color: var(--text2);
}
