/* Lotse - bewusst schlankes, zugaengliches CSS ohne Build-Pipeline. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #55636f;
  --line: #d3dbe3;
  --brand: #1c5d8c;
  --brand-strong: #14476b;
  --focus: #b8560f;
  --warn-bg: #fff3e0;
  --warn-line: #d98324;
  --info-bg: #e8f1f8;
  --danger-bg: #fdecec;
  --danger-line: #b3261e;
  --ok-bg: #e9f5ec;
  --ok-line: #2e7d46;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181e;
    --surface: #1b232b;
    --text: #eef3f7;
    --muted: #a9b6c2;
    --line: #35424f;
    --brand: #6fb3e0;
    --brand-strong: #9ccdf0;
    --focus: #ffb870;
    --warn-bg: #3a2c15;
    --warn-line: #d98324;
    --info-bg: #17303f;
    --danger-bg: #3d1f1d;
    --danger-line: #f2837a;
    --ok-bg: #1a3324;
    --ok-line: #6cc28a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
               "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif;
  /* Grosse Grundschrift: viele Nutzende lesen auf kleinen Handys. */
  font-size: 18px;
  line-height: 1.6;
}

.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }

/* --- Fokus immer deutlich sichtbar (Barrierefreiheit) --- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--text);
  padding: 12px 16px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* --- Header --- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  padding-top: 10px; padding-bottom: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 1.25rem; color: var(--brand); }

.lang-switch { display: flex; align-items: center; gap: 8px; }
.lang-switch label { font-size: 0.95rem; color: var(--muted); }

select, input, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  max-width: 100%;
}

textarea { resize: vertical; min-height: 56px; width: 100%; }

/* --- Karten & Panels --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 18px 0;
}

h1 { font-size: 1.5rem; margin: 0 0 12px; line-height: 1.3; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 { font-size: 1.1rem; margin: 18px 0 8px; }

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: 4px 0; }

/* --- Tabs --- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tab {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
}
.tab[aria-selected="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* --- Buttons --- */
.btn { cursor: pointer; font-weight: 600; border-radius: 8px; padding: 12px 18px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-quiet { background: transparent; color: var(--brand); border-color: var(--line); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --- Chat --- */
.chat-log {
  min-height: 140px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px;
}
.msg { padding: 12px 14px; border-radius: var(--radius); max-width: 92%; }
.msg-user {
  align-self: flex-end;
  background: var(--info-bg);
  border: 1px solid var(--line);
}
.msg-bot {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--line);
}
.msg-error { background: var(--danger-bg); border-color: var(--danger-line); align-self: stretch; }
.msg-urgent { border-left: 6px solid var(--danger-line); }
html[dir="rtl"] .msg-urgent { border-left: none; border-right: 6px solid var(--danger-line); }
.msg-role {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 4px;
}
.msg :is(p, ul, ol):first-child { margin-top: 0; }
.msg :is(p, ul, ol):last-child { margin-bottom: 0; }
.msg a { color: var(--brand); }
.msg blockquote {
  margin: 10px 0; padding: 10px 14px;
  background: var(--warn-bg); border-left: 5px solid var(--warn-line);
  border-radius: 6px;
}
html[dir="rtl"] .msg blockquote { border-left: none; border-right: 5px solid var(--warn-line); }
.msg hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

.chat-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 14px; }
.chat-form textarea { flex: 1; }
.chat-actions { margin: 10px 0 0; }

.typing { color: var(--muted); font-style: italic; }

/* --- Formulare --- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > legend { font-weight: 600; }
fieldset.field { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.radio { display: flex; align-items: center; gap: 10px; font-weight: 400; padding: 4px 0; }
.radio input { width: 20px; height: 20px; }

/* --- Ergebnisse & Hinweise --- */
.result:empty { display: none; }
.result { margin-top: 18px; }

.notice { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); margin: 12px 0; }
.notice-info { background: var(--info-bg); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.notice-danger { background: var(--danger-bg); border-color: var(--danger-line); font-weight: 600; }
.notice-ok { background: var(--ok-bg); border-color: var(--ok-line); }

.deadline-date { font-size: 1.6rem; font-weight: 700; display: block; margin: 6px 0; }
.fineprint { color: var(--muted); font-size: 0.9rem; margin-top: 14px; }

.ocr-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 340px;
  overflow: auto;
  font-size: 0.95rem;
  /* OCR-Text ist immer LTR-Rohtext aus dem Bescheid (deutsch). */
  direction: ltr;
  text-align: start;
}

ul { padding-inline-start: 1.3em; }

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding: 18px 0 32px;
  color: var(--muted);
  font-size: 0.92rem;
}
.site-footer p { margin: 4px 0; }

/* --- RTL --- */
html[dir="rtl"] body { font-family: "Noto Naskh Arabic", "Noto Sans Arabic", system-ui, Tahoma, Arial, sans-serif; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .chat-form { flex-direction: column; align-items: stretch; }
  .msg { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------- Themenbausteine */

.module-grid {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.module-card { margin: 0; }

.module-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  height: 100%;
  padding: 1rem;
  text-align: start;
  font: inherit;
  color: inherit;
  background: var(--surface, #fff);
  border: 2px solid var(--line, #d7dde5);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.module-button:hover,
.module-button:focus-visible {
  border-color: var(--accent, #1c5d99);
  transform: translateY(-1px);
}

.module-icon { font-size: 1.6rem; line-height: 1; }
.module-name { font-weight: 700; font-size: 1.05rem; }
.module-desc { font-size: 0.92rem; line-height: 1.45; opacity: 0.85; }

.module-badge {
  margin-top: 0.35rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 999px;
  background: var(--accent-soft, #e6eff8);
  color: var(--accent, #1c5d99);
}

.module-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent-soft, #e6eff8);
  border-radius: 0.5rem;
  font-weight: 600;
}

/* ------------------------------------------------ Beratungsstellen-Finder */

.referral-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.referral-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line, #d7dde5);
  border-inline-start: 4px solid var(--accent, #1c5d99);
  border-radius: 0.5rem;
  background: var(--surface, #fff);
}

.referral-card h3 { margin: 0 0 0.35rem; font-size: 1.02rem; }
.referral-card p { margin: 0.25rem 0 0; line-height: 1.5; }

/* -------------------------------------------------------- Notfallhinweis */

.emergency {
  border-inline-start: 5px solid #b3261e;
  background: #fdf3f2;
}

.emergency h2 { margin-top: 0; color: #8c1d18; font-size: 1.05rem; }
.emergency p { margin-bottom: 0; }

@media (prefers-color-scheme: dark) {
  .emergency { background: #2a1917; }
  .emergency h2 { color: #f2b8b5; }
}

/* RTL: Symbole und Badges laufen mit der Leserichtung mit. */
[dir="rtl"] .module-button { text-align: right; }
