/* AI-Doktor (ai-doktor.ch) — Medical Information & Privacy-First Design System */
:root {
  --nav: #0f172a;
  --nav-hover: #1e293b;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #f0fdfa;
  --blue: #0284c7;
  --blue-soft: #f0f9ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 250px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14.5px/1.6 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Permanent Top Liability Banner */
.liability-bar {
  background: #fef3c7;
  border-bottom: 1px solid #f59e0b;
  color: #78350f;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 8px 18px;
  text-align: center;
}
.liability-bar strong { color: #78350f; }
.liability-bar a { color: #92400e; text-decoration: underline; font-weight: 700; }

/* Authenticated Layout */
body.authenticated {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
aside.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #132238 100%);
  color: #fff;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  margin: 2px 6px 14px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.workspace-switcher {
  margin: 0 4px 14px;
  padding: 10px;
  border-radius: 9px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.09);
}
.workspace-switcher label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 5px;
  font-weight: 700;
}
.workspace-switcher select {
  width: 100%;
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
}
.workspace-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11px;
  color: #94a3b8;
}
.ws-pill {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(20, 184, 166, 0.25);
  color: #99f6e4;
}
nav.nav-compact { display: grid; gap: 2px; flex: 1; align-content: start; }
.nav-group { margin-bottom: 12px; }
.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 6px 8px 4px;
}
nav a, .nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #cbd5e1;
  padding: 8px 10px;
  border-radius: 8px;
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
nav a:hover, .nav-btn:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
nav a.active {
  background: rgba(15, 118, 110, 0.32);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #2dd4bf;
}
.nav-badge {
  background: #0f766e;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: #94a3b8;
}
.workspace-shell { display: flex; flex-direction: column; min-width: 0; }
main.workspace {
  padding: 24px 28px 48px;
  max-width: 1260px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Public Pages */
body.public-page { background: linear-gradient(180deg, #f0fdfa 0%, #f1f5f9 360px); min-height: 100vh; display: flex; flex-direction: column; }
.pub-nav {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}
.pub-brand:hover { text-decoration: none; }
.pub-brand img { width: 34px; height: 34px; border-radius: 9px; }

.hero {
  max-width: 1120px;
  margin: 12px auto 40px;
  padding: 0 24px;
}
.hero-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.16;
  margin: 0 0 14px;
  letter-spacing: -0.025em;
  max-width: 820px;
}
.hero .lead {
  font-size: 17px;
  color: var(--muted);
  max-width: 760px;
  margin: 0 0 22px;
}

/* Disclaimer & Emergency Callouts */
.disclaimer-box {
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 18px 0 24px;
  color: #78350f;
}
.disclaimer-box h2, .disclaimer-box h3 { margin: 0 0 8px; color: #78350f; font-size: 16px; }
.disclaimer-box p { margin: 0 0 8px; font-size: 13.5px; }
.disclaimer-box p:last-child { margin-bottom: 0; }
.emergency-box {
  background: var(--red-soft);
  border: 2px solid #dc2626;
  border-radius: var(--radius);
  padding: 18px 20px;
  color: #7f1d1d;
  white-space: pre-wrap;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card h1 { margin: 0 0 8px; font-size: 24px; }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h3 { margin: 0 0 8px; font-size: 15.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 26px; font-weight: 800; margin-top: 4px; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Buttons & Badges */
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn, button.primary, button.secondary, button.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary, button.primary { background: var(--accent); color: #fff; }
.btn-primary:hover, button.primary:hover { background: var(--accent-dark); }
.btn-secondary, button.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover, button.secondary:hover { background: #f8fafc; }
.btn-danger, button.danger { background: var(--red); color: #fff; }
.btn-danger:hover, button.danger:hover { background: #991b1b; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-teal { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #99f6e4; }
.badge-green { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border: 1px solid #fde68a; }
.badge-red { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.badge-slate { background: #f1f5f9; color: #334155; border: 1px solid var(--border); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; color: #1e293b; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--accent); }

/* Auth Cards */
.auth-wrap { max-width: 560px; margin: 24px auto 48px; padding: 0 20px; width: 100%; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 30px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* Flash messages */
.flash {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 600;
}
.flash.success { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.flash.error { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.flash.info { background: var(--blue-soft); color: #0369a1; border: 1px solid #bae6fd; }

/* Chat Messages */
.chat-thread { display: grid; gap: 14px; margin: 16px 0 20px; }
.msg-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border);
}
.msg-user { background: #f0f9ff; border-color: #bae6fd; margin-left: 28px; }
.msg-assistant { background: #ffffff; border-color: #99f6e4; margin-right: 28px; }
.msg-system_notice { background: #f8fafc; border-color: var(--border-strong); }
.msg-system_emergency { background: var(--red-soft); border: 2px solid #dc2626; color: #7f1d1d; }
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body ul { margin: 6px 0 10px; padding-left: 20px; }
.msg-footnote {
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px dashed var(--border-strong);
  font-size: 11.5px;
  color: var(--muted);
}

/* Tables & Lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #f8fafc; }

/* Legal & Footer */
.legal-wrap { max-width: 920px; margin: 20px auto 48px; padding: 0 20px; width: 100%; }
.legal-doc h2 { margin-top: 22px; }
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 18px 24px;
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.app-footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.muted { color: var(--muted); }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

@media (max-width: 920px) {
  body.authenticated { grid-template-columns: 1fr; }
  aside.sidebar { position: static; height: auto; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: 1fr; }
  .msg-user, .msg-assistant { margin-left: 0; margin-right: 0; }
  main.workspace { padding: 16px; }
}

@media print {
  aside.sidebar, .no-print, .liability-bar { display: none !important; }
  body.authenticated { display: block; }
  main.workspace { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #94a3b8; }
}
