/* RVE-Sicherheitstraining – Stylesheet
   Vereinsfarbe Blau, mobil zuerst, Light- und Dark-Mode. */

:root {
  --blue:        #0d5aa7;
  --blue-dark:   #09477f;
  --blue-deep:   #063461;
  --blue-soft:   #e7f0fa;
  --blue-line:   #b9d3ec;

  --bg:          #f1f6fb;
  --surface:     #ffffff;
  --surface-2:   #f7fafd;
  --text:        #17222e;
  --muted:       #5a6b7d;
  --border:      #d7e2ee;

  --ok:          #167c45;
  --ok-soft:     #e3f5ea;
  --ok-line:     #a8ddbe;
  --bad:         #b8342a;
  --bad-soft:    #fdecea;
  --bad-line:    #f0b7b1;
  --warn:        #a06407;
  --warn-soft:   #fff4e0;
  --warn-line:   #f0d199;
  --key-bg:      #fff6c9;
  --key-line:    #e8cf6a;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 1px 2px rgba(9, 45, 80, .06), 0 6px 18px rgba(9, 45, 80, .07);
  --shadow-lg:   0 10px 40px rgba(9, 45, 80, .18);
  --gutter:      16px;
  --maxw:        780px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue:        #4d9ce6;
    --blue-dark:   #6fb3f0;
    --blue-deep:   #0e2033;
    --blue-soft:   #16293d;
    --blue-line:   #27435f;

    --bg:          #0c1622;
    --surface:     #131f2d;
    --surface-2:   #18273a;
    --text:        #e6eef7;
    --muted:       #9bb0c6;
    --border:      #24374d;

    --ok:          #63c98d;
    --ok-soft:     #14301f;
    --ok-line:     #2d6b47;
    --bad:         #f0837a;
    --bad-soft:    #351a19;
    --bad-line:    #7a3a34;
    --warn:        #e9b45b;
    --warn-soft:   #33260f;
    --warn-line:   #6d5423;
    --key-bg:      #33300f;
    --key-line:    #6f6725;

    --shadow:      0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    --shadow-lg:   0 10px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.06rem; }
p  { margin: 0 0 .9em; }
a  { color: var(--blue); }

/* ---------- Layout ---------------------------------------------------- */
.topbar {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff;
  padding: 14px var(--gutter);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 12px rgba(6, 52, 97, .25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar {
    background: linear-gradient(135deg, #10263c, #1b3f63);
  }
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .16);
  display: grid; place-items: center;
  font-size: 18px;
}
.brand-text { min-width: 0; }
.brand-title {
  font-weight: 700; font-size: .98rem; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: .76rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }

.topbar-user {
  font-size: .82rem;
  background: rgba(255, 255, 255, .15);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px var(--gutter) 64px;
}
.wrap-wide { max-width: 1180px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-tight { padding: 14px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

/* ---------- Buttons --------------------------------------------------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
  transition: filter .15s, background .15s, border-color .15s;
  min-height: 44px;
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: .86rem; }
.btn-block { width: 100%; }
.btn-link {
  background: none; border: none; color: var(--blue);
  padding: 4px; cursor: pointer; font: inherit; text-decoration: underline;
  min-height: auto;
}

/* ---------- Formulare ------------------------------------------------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
  width: 100%;
  padding: 12px 13px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 44px;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: .9rem;
  margin-bottom: 14px;
  border: 1px solid;
}
.alert-error { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.alert-ok    { background: var(--ok-soft);  border-color: var(--ok-line);  color: var(--ok); }
.alert-warn  { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

/* ---------- Start / Hero ---------------------------------------------- */
.hero {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff;
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero { background: linear-gradient(135deg, #10263c, #1b3f63); }
}
.hero h1 { margin: 0 0 6px; font-size: 1.45rem; }
.hero p { margin: 0; opacity: .92; font-size: .94rem; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero-badge {
  background: rgba(255, 255, 255, .17);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 600;
}

/* ---------- Fortschritt ----------------------------------------------- */
.progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .85rem; margin-bottom: 7px;
}
.progress-track {
  height: 9px;
  background: var(--blue-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  border-radius: 999px;
  transition: width .35s ease;
}

/* ---------- Modulliste ------------------------------------------------ */
.module-list { display: grid; gap: 11px; }
.module-item {
  display: flex; align-items: center; gap: 13px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.module-item:hover { border-color: var(--blue-line); }
.module-item:active { transform: scale(.995); }
.module-item:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.module-icon {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 11px;
  background: var(--blue-soft);
  display: grid; place-items: center;
  font-size: 20px;
}
.module-body { flex: 1; min-width: 0; }
.module-title { font-weight: 650; }
.module-meta { font-size: .82rem; color: var(--muted); }
.module-state { flex: 0 0 auto; font-size: .78rem; font-weight: 700; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  border: 1px solid;
  white-space: nowrap;
}
.badge-todo { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.badge-open { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue); }
.badge-done { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.badge-bad  { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

/* ---------- Lerninhalte ----------------------------------------------- */
.lesson-head { margin-bottom: 14px; }
.lesson-kicker {
  font-size: .78rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--blue);
}
.section + .section {
  margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border);
}
.section h3 { color: var(--blue); }
.section ul { margin: 0 0 .9em; padding-left: 1.15em; }
.section li { margin-bottom: .45em; }
.section li.key {
  list-style: none;
  margin-left: -1.15em;
  padding: 7px 11px 7px 12px;
  background: var(--key-bg);
  border-left: 4px solid var(--key-line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: 550;
}
.callout {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 .9em;
  border: 1px solid;
  font-size: .95rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.callout-icon { flex: 0 0 auto; font-size: 1.05rem; line-height: 1.4; }
.callout-warn { background: var(--bad-soft); border-color: var(--bad-line); }
.callout-tip  { background: var(--blue-soft); border-color: var(--blue-line); }
.callout-key  { background: var(--key-bg); border-color: var(--key-line); font-weight: 550; }

.table-scroll { overflow-x: auto; margin: 0 0 .9em; -webkit-overflow-scrolling: touch; }
table.content {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
  min-width: 420px;
}
table.content th, table.content td {
  border: 1px solid var(--border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}
table.content th { background: var(--blue-soft); font-weight: 650; }
table.content td:first-child { font-weight: 600; white-space: nowrap; }
table.content.wrapcell td:first-child { white-space: normal; }

/* ---------- Quiz ------------------------------------------------------ */
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; color: var(--muted); margin-bottom: 10px;
}
.quiz-question { font-size: 1.08rem; font-weight: 650; margin-bottom: 14px; }
.options { display: grid; gap: 9px; margin-bottom: 14px; }
.option {
  display: flex; align-items: flex-start; gap: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  width: 100%;
  transition: border-color .15s, background .15s;
}
.option:hover:not(.locked) { border-color: var(--blue); background: var(--blue-soft); }
.option:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.option.selected { border-color: var(--blue); background: var(--blue-soft); }
.option.locked { cursor: default; }
.option-mark {
  flex: 0 0 22px; width: 22px; height: 22px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 800; color: #fff;
  margin-top: 1px;
}
.option-mark.radio { border-radius: 50%; }
.option-mark.check { border-radius: 6px; }
.option.selected .option-mark { border-color: var(--blue); background: var(--blue); }
.option.is-correct { border-color: var(--ok-line); background: var(--ok-soft); }
.option.is-correct .option-mark { border-color: var(--ok); background: var(--ok); }
.option.is-wrong { border-color: var(--bad-line); background: var(--bad-soft); }
.option.is-wrong .option-mark { border-color: var(--bad); background: var(--bad); }
.option-text { flex: 1; }

.feedback {
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-bottom: 14px;
  border: 1px solid;
  animation: pop .2s ease;
}
.feedback-title { font-weight: 700; margin-bottom: 4px; }
.feedback.ok  { background: var(--ok-soft);  border-color: var(--ok-line); }
.feedback.ok .feedback-title { color: var(--ok); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.feedback.bad .feedback-title { color: var(--bad); }
.feedback p:last-child { margin-bottom: 0; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.dots { display: flex; gap: 5px; flex-wrap: wrap; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border);
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.now { background: var(--blue); transform: scale(1.35); }

/* ---------- Ergebnis -------------------------------------------------- */
.score {
  text-align: center;
  padding: 10px 0 4px;
}
.score-value { font-size: 3.1rem; font-weight: 750; line-height: 1; color: var(--blue); }
.score-value.pass { color: var(--ok); }
.score-value.fail { color: var(--bad); }
.score-label { font-size: .92rem; color: var(--muted); margin-top: 6px; }
.score-verdict {
  display: inline-block; margin-top: 12px;
  padding: 8px 18px; border-radius: 999px;
  font-weight: 700; border: 1px solid;
}

.mod-score { display: grid; gap: 11px; }
.mod-score-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.mod-score-name { font-size: .92rem; font-weight: 600; }
.mod-score-num { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-track {
  grid-column: 1 / -1;
  height: 7px; background: var(--blue-soft); border-radius: 999px; overflow: hidden;
}
.mini-fill { height: 100%; background: var(--blue); border-radius: 999px; }
.mini-fill.full { background: var(--ok); }
.mini-fill.low  { background: var(--bad); }

/* ---------- Admin ----------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; margin-bottom: 16px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--blue); }
.stat-label { font-size: .8rem; color: var(--muted); }

.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 720px) {
  .toolbar { grid-template-columns: 1fr auto auto auto; align-items: center; }
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 760px; }
table.data th, table.data td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); }
table.data thead th {
  background: var(--surface-2);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700;
  position: sticky; top: 0; z-index: 2;
  cursor: pointer; white-space: nowrap;
}
table.data thead th.nosort { cursor: default; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sort-arrow { opacity: .5; font-size: .7rem; }

.name-cell { font-weight: 600; }
.pct { font-weight: 700; }
.pct.pass { color: var(--ok); }
.pct.fail { color: var(--bad); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Karten-Ansicht für Handy statt breiter Tabelle */
.card-list { display: grid; gap: 10px; }
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
}
.result-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.result-card-meta { font-size: .81rem; color: var(--muted); margin-top: 2px; }
.result-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

@media (max-width: 719px) { .desktop-only { display: none !important; } }
@media (min-width: 720px) { .mobile-only { display: none !important; } }

/* ---------- Modal ----------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 26, 44, .55);
  display: grid; place-items: center;
  padding: var(--gutter);
  z-index: 60;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(720px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: 1px solid var(--border);
}
.modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-body { padding: 18px; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 9px;
  position: sticky; bottom: 0; background: var(--surface);
}
.icon-btn {
  background: none; border: none; font-size: 1.4rem; line-height: 1;
  cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.answer-list { display: grid; gap: 7px; }
.answer-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: .89rem;
}
.answer-row.ok  { background: var(--ok-soft);  border-color: var(--ok-line); }
.answer-row.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.answer-row.na  { background: var(--surface-2); }
.answer-mark { flex: 0 0 auto; font-weight: 800; }
.answer-detail { font-size: .83rem; color: var(--muted); margin-top: 3px; }

/* ---------- Drucken --------------------------------------------------- */
@media print {
  .topbar, .no-print, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
