/* ============================================================
   MILO DIALOG – Design System
   Seniorengerecht: XXL-Flächen, hoher Kontrast, ruhige Farben
   ============================================================ */

:root {
  --teal: #0F766E;
  --teal-dunkel: #0B5A54;
  --teal-hell: #D8EEEC;
  --coral: #E85D3D;
  --coral-hell: #FDE4DC;
  --ink: #10201E;
  --muted: #5C6B69;
  --line: #D8E2E0;
  --bg: #F4F8F7;
  --surface: #FFFFFF;
  --gruen: #15803D;
  --gruen-hell: #DCFCE7;
  --rot: #C2261F;
  --rot-hell: #FDE2E0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 6px rgba(16, 32, 30, .08), 0 8px 24px rgba(16, 32, 30, .06);
  --shadow-lg: 0 12px 48px rgba(16, 32, 30, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Barrierefreiheit: klarer Fokus-Ring fuer Tastatur-/Schalter-Bedienung */
:focus-visible {
  outline: 4px solid var(--coral);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; }

.hidden { display: none !important; }

[dir="rtl"] { direction: rtl; }

/* ------------------------------------------------------------ Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 18px;
  background: var(--teal);
  color: #fff;
}

.topbar .brand {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .03em;
  white-space: nowrap;
}

.topbar .brand small { font-weight: 600; opacity: .8; }
.topbar .spacer { flex: 1; }

.topbar .wer {
  font-size: 16px;
  font-weight: 600;
  opacity: .92;
  text-align: right;
  line-height: 1.2;
}

.btn-topbar {
  border: 2px solid rgba(255, 255, 255, .4);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 99px;
  min-height: 48px;
}

.btn-topbar:active { background: rgba(255, 255, 255, .22); }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  padding: 14px 26px;
  min-height: 56px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:active { background: var(--teal-dunkel); }
.btn-coral { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-danger { color: var(--rot); border-color: var(--rot); background: #fff; }
.btn-sm { min-height: 44px; padding: 8px 16px; font-size: 16px; }

/* ------------------------------------------------------------ Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--teal) 0%, #0A4A45 100%);
}

.login-logo {
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.login-sub { color: rgba(255, 255, 255, .8); font-size: 18px; margin-bottom: 28px; }

.login-card {
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
  width: 420px;
  max-width: 100%;
  text-align: center;
}

.login-card h2 { font-size: 24px; margin-bottom: 4px; }
.login-card .hinweis { color: var(--muted); font-size: 17px; margin-bottom: 18px; }

.code-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 10px 0 22px;
  min-height: 26px;
}

.code-dots span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--line);
}

.code-dots span.voll { background: var(--teal); border-color: var(--teal); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.keypad button {
  height: 84px;
  font-size: 34px;
  font-weight: 800;
  border-radius: 20px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.keypad button:active { background: var(--teal-hell); border-color: var(--teal); }
.keypad button.klein { font-size: 20px; font-weight: 700; color: var(--muted); }

.login-fehler {
  background: var(--rot-hell);
  color: var(--rot);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 700;
  padding: 12px;
  margin-bottom: 14px;
  animation: shake .3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.admin-link {
  margin-top: 22px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, .75);
  font-size: 16px;
  text-decoration: underline;
}

.login-card label { display: block; text-align: left; margin-bottom: 14px; }
.login-card label span { display: block; font-size: 15px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }

input, select, textarea {
  font: inherit;
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 54px;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15, 118, 110, .18); }

/* ------------------------------------------------------------ Home */
.home-wrap { max-width: 900px; margin: 0 auto; padding: 30px 20px 60px; }

.home-gruss { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.home-sub { color: var(--muted); font-size: 18px; margin-bottom: 26px; }

.home-karten { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.home-karte {
  background: var(--surface);
  border: 3px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 40px 24px;
  text-align: center;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.home-karte:active { border-color: var(--teal); background: var(--teal-hell); }
.home-karte .icon { font-size: 64px; }
.home-karte .titel { font-size: 26px; font-weight: 800; }
.home-karte .unter { color: var(--muted); font-size: 17px; }

@media (max-width: 700px) {
  .home-karten { grid-template-columns: 1fr; }
}

/* Notruf-Kachel spannt die volle Breite (beide oberen Kacheln) */
.karte-notruf, .karte-gesperrt { grid-column: 1 / -1; min-height: 160px; }

.karte-notruf { border-color: var(--coral); }
.karte-notruf:active { border-color: var(--rot); background: var(--coral-hell); }
.karte-notruf .titel { color: var(--rot); }

.karte-kamera { grid-column: 1 / -1; min-height: 150px; }

.karte-gesperrt { position: relative; }

/* ------------------------------------------------------------ Kamera-Übersetzung */
.kamera-wrap { max-width: 800px; margin: 0 auto; padding: 18px 16px 60px; }

.kam-foto-btn {
  width: 100%;
  margin-top: 16px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.kam-foto-btn:active { background: var(--teal-dunkel); }
.kam-foto-btn .kam-sub { font-size: 15px; font-weight: 600; opacity: .85; }

.card-kam { margin-top: 18px; padding: 16px; }
.kam-vorschau { width: 100%; max-height: 240px; object-fit: contain; border-radius: 12px; background: var(--bg); margin-bottom: 12px; }

.kam-block { padding: 12px 0; }
.kam-block-ziel { border-top: 2px solid var(--line); }
.kam-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.kam-orig { font-size: 16px; color: #3a4644; white-space: pre-wrap; }
.kam-ziel { font-size: 24px; font-weight: 700; line-height: 1.4; white-space: pre-wrap; }

.kam-aktionen { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.upgrade-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 99px;
}

/* ------------------------------------------------------------ Sprachtafel */
.tafel-wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 130px; }

.richtung-wahl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.richtung-btn {
  border: 3px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 14px 10px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 20px;
  font-weight: 800;
  color: var(--muted);
}

.richtung-btn .r-flaggen { font-size: 24px; }
.richtung-btn .r-sub { font-size: 14px; font-weight: 600; opacity: .75; }
.richtung-btn.aktiv { border-color: var(--teal); background: var(--teal-hell); color: var(--teal-dunkel); }

.tile-emoji { font-size: 34px; line-height: 1; }

.tile { position: relative; }

.tile-neu { border-style: dashed; color: var(--muted); }
.tile-neu .tile-emoji { color: var(--teal); }

.tile-eigen { cursor: pointer; }

.tile-loeschen {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-loeschen:active { background: var(--rot-hell); color: var(--rot); border-color: var(--rot); }

.emoji-reihe {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin: 14px 0 4px;
}

.emoji-btn {
  font-size: 26px;
  padding: 8px 0;
  min-height: 52px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
}

.emoji-btn.aktiv { border-color: var(--teal); background: var(--teal-hell); }

.btn-breit { width: 100%; max-width: 900px; margin: 0 auto; font-size: 21px; min-height: 64px; }

.kat-leiste {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 14px;
  -webkit-overflow-scrolling: touch;
}

/* Auf schmalen Geraeten umbrechen statt seitlich scrollen – sonst ist z.B.
   die Notfall-Kategorie unerreichbar (Senioren wischen nicht horizontal). */
@media (max-width: 900px) {
  .kat-leiste { flex-wrap: wrap; overflow-x: visible; }
  .kat-btn { flex: 0 1 auto; }
}

.kat-btn {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 20px;
  min-height: 56px;
  border-radius: 99px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}

.kat-btn.aktiv { background: var(--teal); border-color: var(--teal); color: #fff; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.tile {
  background: var(--surface);
  border: 3px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px 16px;
  min-height: 120px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.tile:active { border-color: var(--teal); background: var(--teal-hell); }
.tile .eigen { font-size: 23px; font-weight: 800; line-height: 1.25; }
.tile .deutsch { font-size: 15px; color: var(--muted); }
.tile.gross { border-color: var(--coral); }
.tile.gross .eigen { font-size: 30px; color: var(--coral); }
.tile.wird-gesprochen { border-color: var(--teal); background: var(--teal-hell); }

.eigentext-leiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  max-width: 100%;
}

.eigentext-leiste input { flex: 1; font-size: 20px; }

/* ------------------------------------------------------------ Sprech-Overlay */
.sprech-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 90, 84, .96);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  color: #fff;
}

.sprech-overlay .icon { font-size: 60px; margin-bottom: 18px; animation: puls 1.2s infinite; }
.sprech-overlay .text { font-size: clamp(28px, 6vw, 52px); font-weight: 800; line-height: 1.3; max-width: 900px; }
.sprech-overlay .klein { margin-top: 14px; font-size: 20px; opacity: .8; }

@keyframes puls {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: .75; }
}

/* ------------------------------------------------------------ Dialog / Dolmetscher */
.dialog-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 14px 320px;
}

html { scroll-padding-bottom: 320px; }

.chat-verlauf { display: flex; flex-direction: column; gap: 14px; padding: 10px 2px 20px; }

.bubble {
  max-width: 82%;
  border-radius: 22px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
}

.bubble .orig { font-size: 16px; opacity: .75; margin-bottom: 4px; }
.bubble .uebersetzt { font-size: 22px; font-weight: 700; line-height: 1.35; }
.bubble .replay { margin-top: 8px; font-size: 15px; font-weight: 700; opacity: .8; }

.bubble.von-pflege { align-self: flex-start; background: var(--surface); border-color: var(--line); }
.bubble.von-patient { align-self: flex-end; background: var(--teal); color: #fff; }
.bubble.fehler { align-self: center; background: var(--rot-hell); color: var(--rot); font-weight: 700; font-size: 17px; }

.chat-leer { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 18px; }

.mik-leiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--line);
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
}

.mik-interim {
  min-height: 30px;
  text-align: center;
  font-size: 19px;
  color: var(--muted);
  padding-bottom: 10px;
  font-style: italic;
}

.mik-knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 900px; margin: 0 auto; }

.mik-btn {
  min-height: 108px;
  border-radius: 24px;
  border: 3px solid var(--line);
  font-size: 21px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
}

.mik-btn .mik-icon { font-size: 34px; }
.mik-btn .mik-sub { font-size: 15px; font-weight: 600; opacity: .75; }
.mik-btn.pflege { background: var(--surface); color: var(--ink); }
.mik-btn.patient { background: var(--teal); border-color: var(--teal); color: #fff; }
.mik-btn.hoert { border-color: var(--coral) !important; background: var(--coral-hell) !important; color: var(--coral) !important; animation: puls 1.2s infinite; }

.tippen-zeile { display: flex; gap: 8px; max-width: 900px; margin: 10px auto 0; }
.tippen-zeile input { flex: 1; }

/* ------------------------------------------------------------ Admin (Mini-CRM) */
.admin-wrap { max-width: 1080px; margin: 0 auto; padding: 26px 20px 80px; font-size: 16px; }

.admin-kopf { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-kopf h1 { font-size: 26px; }
.admin-kopf .sub { color: var(--muted); font-size: 15px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 { font-size: 19px; margin-bottom: 14px; }

table.admin-tab { width: 100%; border-collapse: collapse; font-size: 15.5px; }

.admin-tab th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
}

.admin-tab td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }

.code-pill {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .18em;
  background: var(--teal-hell);
  color: var(--teal-dunkel);
  border-radius: 10px;
  padding: 5px 12px;
  white-space: nowrap;
}

.badge { display: inline-block; font-size: 13px; font-weight: 800; border-radius: 99px; padding: 4px 12px; }
.badge-aktiv { background: var(--gruen-hell); color: var(--gruen); }
.badge-inaktiv { background: var(--rot-hell); color: var(--rot); }
.badge-sprache { background: #EDF1F0; color: var(--ink); font-weight: 700; }

.zeilen-aktionen { display: flex; gap: 6px; flex-wrap: wrap; }
.zeilen-aktionen .btn { min-height: 40px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.form-grid label, .modal label { display: block; margin-bottom: 12px; }
.form-grid label span, .modal label span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }

/* ------------------------------------------------------------ Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 30, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px;
}

.modal h2 { font-size: 21px; margin-bottom: 16px; }
.modal-aktionen { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

#toast-root {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: max-content;
  max-width: 92vw;
}

.toast {
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: 99px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.toast.toast-error { background: var(--rot); }
.toast.toast-success { background: var(--gruen); }

.offline-banner {
  background: var(--coral);
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  padding: 8px 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 50px auto;
}

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