/* AufklaerungPro – Design System */
/* Kein Google Fonts. System-Font-Stack (DSGVO-konform) */

:root {
  --primary: #1a6b8a;
  --primary-dark: #145a75;
  --primary-light: #e8f4f8;
  --primary-xlight: #f0f9fc;
  --accent: #10a37f;
  --accent-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fff8e1;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w: 240px;
  --header-h: 60px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typografie ─────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { margin-bottom: .75rem; }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  grid-column: 1 / -1;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  z-index: 100;
  position: sticky;
  top: 0;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -.01em;
}

.app-header .logo-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.2);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.header-spacer { flex: 1; }

.header-info {
  font-size: .8125rem;
  opacity: .85;
  text-align: right;
}

.header-info strong { display: block; opacity: 1; }

.btn-header {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  padding: .375rem .875rem;
  border-radius: var(--radius);
  font-size: .8125rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-header:hover { background: rgba(255,255,255,.25); }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: white;
  border-right: 1px solid var(--border-light);
  padding: 1.25rem 0;
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
}

.nav-section-title {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  padding: .75rem 1.25rem .25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5625rem 1.25rem;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: all .12s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover { background: var(--primary-xlight); color: var(--primary); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; font-size: .9375rem; }

/* ── Hauptinhalt ─────────────────────────────────────────── */
.main-content {
  padding: 2rem;
  overflow-y: auto;
  max-width: 1200px;
}

/* ── Karten ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }

/* ── Stats-Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.blue  { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--accent-light); color: var(--accent); }
.stat-icon.orange{ background: var(--warning-light); color: var(--warning); }
.stat-icon.gray  { background: #f3f4f6; color: var(--text-muted); }

.stat-number { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: .8125rem; color: var(--text-muted); margin-top: .125rem; }

/* ── Tabellen ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--bg);
  padding: .625rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:hover { background: var(--primary-xlight); }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  padding: .5rem 1.125rem;
  font-size: .875rem; font-weight: 600;
  border-radius: var(--radius);
  border: none; cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-success   { background: var(--accent); color: white; }
.btn-success:hover { background: #0d8a6a; }

.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-xlight); }

.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

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

.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-icon { padding: .5rem; width: 36px; height: 36px; }
.btn-full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .1875rem .625rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  line-height: 1;
}
.badge-blue    { background: var(--primary-light); color: var(--primary); }
.badge-green   { background: var(--accent-light); color: #065f46; }
.badge-orange  { background: var(--warning-light); color: #92400e; }
.badge-gray    { background: #f3f4f6; color: var(--text-muted); }
.badge-red     { background: var(--danger-light); color: var(--danger); }

/* ── Formularelemente ────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .875rem; font-weight: 600;
  margin-bottom: .375rem;
  color: var(--text);
}
.form-label.required::after { content: ' *'; color: var(--danger); }

.form-control {
  width: 100%;
  padding: .5625rem .875rem;
  font-size: .9375rem;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,107,138,.15);
}
.form-control::placeholder { color: var(--text-light); }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-control-lg { padding: .75rem 1rem; font-size: 1rem; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }

.form-hint { font-size: .8125rem; color: var(--text-muted); margin-top: .25rem; }

/* Checkbox & Radio */
.form-check { display: flex; align-items: flex-start; gap: .625rem; margin-bottom: .5rem; cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  accent-color: var(--primary); cursor: pointer;
}
.form-check-label { font-size: .9375rem; line-height: 1.4; cursor: pointer; }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 1.375rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-title { font-size: 1.0625rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.375rem; color: var(--text-muted); line-height: 1; padding: .25rem; }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); display: flex; gap: .75rem; justify-content: flex-end; }

/* ── QR-Code Modal ────────────────────────────────────────── */
.qr-container {
  text-align: center;
  padding: 1rem;
}
.qr-container img { width: 240px; height: 240px; border: 8px solid white; box-shadow: var(--shadow-md); border-radius: var(--radius); }
.qr-url {
  margin-top: 1rem;
  font-size: .8125rem;
  color: var(--text-muted);
  word-break: break-all;
  background: var(--bg);
  padding: .625rem;
  border-radius: var(--radius);
  font-family: monospace;
}

/* ── Signatur-Pad ─────────────────────────────────────────── */
.signature-wrap {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  position: relative;
  overflow: hidden;
}
.signature-wrap canvas { display: block; touch-action: none; }
.signature-wrap .sig-hint {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  font-size: .875rem;
  pointer-events: none;
}
.signature-wrap.signed { border-color: var(--accent); background: #f0fdf9; }

/* ── Patienten-Formular (Kiosk) ──────────────────────────── */
.kiosk-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.kiosk-header {
  background: var(--primary);
  color: white;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kiosk-header .logo-text { font-size: 1.125rem; font-weight: 700; }
.kiosk-header .praxis-name { font-size: .9375rem; opacity: .85; }

.kiosk-body {
  flex: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  width: 100%;
}

.kiosk-progress {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 2rem;
}

.kiosk-progress-step {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-weight: 700; font-size: .875rem;
  border: 2px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all .2s;
}
.kiosk-progress-step.active { background: var(--primary); border-color: var(--primary); color: white; }
.kiosk-progress-step.done   { background: var(--accent); border-color: var(--accent); color: white; }

.kiosk-progress-line { flex: 1; height: 2px; background: var(--border); transition: background .2s; }
.kiosk-progress-line.done { background: var(--accent); }

.kiosk-section {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.kiosk-section-title {
  font-size: 1.0625rem; font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--primary-light);
  display: flex; align-items: center; gap: .5rem;
}

/* Seniorenmodus: Größere Touch-Targets */
.senior-mode .form-control { font-size: 1.125rem; padding: .75rem 1rem; }
.senior-mode .form-check input { width: 24px; height: 24px; }
.senior-mode .form-check-label { font-size: 1.0625rem; }
.senior-mode .btn-lg { font-size: 1.125rem; padding: 1rem 2rem; }
.senior-mode .kiosk-section-title { font-size: 1.25rem; }

/* ── Disclaimer-Box ───────────────────────────────────────── */
.disclaimer-box {
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: .875rem 1.125rem;
  font-size: .8125rem;
  color: #78350f;
  display: flex;
  gap: .625rem;
  align-items: flex-start;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* ── Readonly-Feld ────────────────────────────────────────── */
.readonly-field {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Checklisten ─────────────────────────────────────────── */
.checklist-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-light);
  margin-bottom: .5rem;
  cursor: pointer;
  transition: all .12s;
}
.checklist-item:hover { border-color: var(--primary); background: var(--primary-xlight); }
.checklist-item.checked { border-color: var(--accent); background: var(--accent-light); }
.checklist-item input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; accent-color: var(--accent); }
.checklist-item label { font-size: .9375rem; line-height: 1.5; cursor: pointer; }

/* ── Audit-Log ───────────────────────────────────────────── */
.audit-entry {
  display: flex; gap: 1rem;
  padding: .75rem;
  border-bottom: 1px solid var(--border-light);
  font-size: .8125rem;
}
.audit-entry:last-child { border-bottom: none; }
.audit-time { color: var(--text-muted); white-space: nowrap; font-size: .75rem; }
.audit-action { font-weight: 600; color: var(--primary); }
.audit-details { color: var(--text-muted); }

/* ── Login / Setup ───────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, #1a8a6b 100%);
  padding: 1.5rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 420px;
  padding: 2.5rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto .75rem;
}

.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ── Template-Builder ─────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 1.5rem;
  height: calc(100vh - var(--header-h) - 4rem);
}

.builder-panel {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.builder-panel-header {
  padding: .875rem 1rem;
  font-size: .875rem; font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .75rem;
}

.builder-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Drag & Drop */
.field-block {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem;
  margin-bottom: .625rem;
  cursor: grab;
  position: relative;
  transition: all .12s;
}
.field-block:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.field-block.dragging { opacity: .4; }
.field-block.dragover { border-color: var(--accent); background: var(--accent-light); }
.field-block .field-type-badge { font-size: .7rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.field-block .field-label-preview { font-weight: 600; font-size: .9rem; }

.field-palette-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .875rem;
  border-radius: var(--radius);
  cursor: grab;
  font-size: .875rem;
  border: 1px solid var(--border-light);
  margin-bottom: .375rem;
  background: white;
  transition: all .12s;
}
.field-palette-item:hover { background: var(--primary-xlight); border-color: var(--primary); color: var(--primary); }
.field-palette-item .icon { width: 20px; text-align: center; }

/* ── Notifications / Toast ───────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}

.toast {
  background: var(--text);
  color: white;
  padding: .875rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .75rem;
  min-width: 280px;
  animation: slideIn .2s ease;
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(40px); } }
.toast.hiding { animation: fadeOut .2s ease forwards; }

/* ── Leer-Zustände ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { margin-bottom: .5rem; color: var(--text); }

/* ── Loader ──────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex; align-items: center; justify-content: center;
  padding: 4rem; color: var(--text-muted);
  gap: .875rem; font-size: .9375rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) auto 1fr;
  }
  .sidebar {
    position: fixed; left: -100%; top: var(--header-h);
    height: calc(100vh - var(--header-h));
    width: var(--sidebar-w);
    z-index: 200;
    transition: left .25s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .builder-layout { grid-template-columns: 1fr; grid-template-rows: auto; }
  .kiosk-body { padding: 1.25rem .875rem; }
}

@media print {
  .sidebar, .app-header, .btn, .modal-overlay { display: none !important; }
  .main-content { padding: 0; }
}
