/* Prüfungsportal – UI im Relution-Design (Corporate Identity).
   Grün #95b507 als Primärfarbe, dunkelgraue Navigation, Selawik-Schrift,
   flache Material-Buttons, weiße Karten mit feinem Rand. Selbstgehostet,
   CSP-konform (keine externen Fonts/CDNs, kein Inline-CSS/JS). */

/* ================= Selawik (selbstgehostet) ================= */
@font-face {
  font-family: "Selawik";
  src: url("/static/fonts/Selawik-Light.woff2") format("woff2"),
       url("/static/fonts/Selawik-Light.woff") format("woff"),
       url("/static/fonts/Selawik-Light.ttf") format("truetype");
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Selawik";
  src: url("/static/fonts/Selawik-Regular.woff2") format("woff2"),
       url("/static/fonts/Selawik-Regular.woff") format("woff"),
       url("/static/fonts/Selawik-Regular.ttf") format("truetype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Selawik";
  src: url("/static/fonts/Selawik-Bold.woff2") format("woff2"),
       url("/static/fonts/Selawik-Bold.woff") format("woff"),
       url("/static/fonts/Selawik-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ================= Design-Tokens (Relution CI) ================= */
:root {
  --primary: #95b507;          /* Relution-Grün */
  --primary-dark: #84a006;
  --primary-tint: rgba(149, 181, 7, .08);
  --accent: #45a4ff;           /* Info-Blau */
  --danger: #d04500;
  --danger-tint: rgba(208, 69, 0, .06);
  --warning: #ffa000;

  --sidenav: #414141;          /* Navigation dunkelgrau */
  --sidenav-header: #2b303c;   /* Kopf/Topbar Anthrazit */
  --sidenav-hover: #3a3a3a;
  --sidenav-item: rgba(255, 255, 255, .6);

  --bg: #fafafa;
  --bg-dark: #272727;          /* Teilnehmer-Hintergrund (wie Relution-Portal) */
  --card: #ffffff;
  --text: #3c3c3c;
  --text-strong: rgba(0, 0, 0, .87);
  --muted: #666666;
  --muted-light: #999999;
  --line: #e0e0e0;
  --line-soft: #eeeeee;
  --table-head: #2f3441;
  --table-alt: #fafafa;

  --ok: #6f8a00;               /* dunkleres Grün für Text/Badges auf Weiß */
  --radius: 2px;
  --radius-btn: 4px;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-2: 0 3px 6px rgba(0, 0, 0, .12), 0 2px 4px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Selawik", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 0.875rem; line-height: 1.42857;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 300; color: var(--text-strong); margin: 0 0 .25rem; }
h2 { font-size: 1.125rem; font-weight: 700; color: var(--text-strong); margin: 1.75rem 0 .75rem; }
strong { font-weight: 700; }
p.sub { color: var(--muted); margin: 0 0 1.75rem; }
p.sub a { color: var(--primary-dark); }

/* ---------- Buttons (flache Material-Buttons) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--primary); color: #fff;
  padding: .55rem 1.15rem; border-radius: var(--radius-btn);
  box-shadow: var(--shadow-1); line-height: 1.2;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); color: #fff; box-shadow: var(--shadow-2); text-decoration: none; }
.btn:active { box-shadow: var(--shadow-1); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none; font-weight: 500; }
.btn.secondary:hover { background: #f2f2f2; color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); box-shadow: none; font-weight: 500; }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); }
.btn.small { padding: .32rem .7rem; font-size: .8rem; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ---------- Formulare ---------- */
label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=file], textarea, select {
  width: 100%; padding: .55rem .7rem; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-btn); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: .4rem .5rem; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-tint);
}
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
.field { margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c3 { grid-template-columns: 1fr 1fr 1fr; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* ---------- Karten / Panels ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  padding: 1.5rem; margin-bottom: 1.25rem;
}
.card h2:first-child { margin-top: 0; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; color: var(--table-head); font-weight: 700; font-size: .8rem;
     padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: rgba(0, 0, 0, .03); }
th:first-child, td:first-child { padding-left: 4px; }
code.voucher { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .95em;
               background: #f4f4f4; padding: .15rem .4rem; border-radius: var(--radius); letter-spacing: .05em; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .2rem .6rem;
         border-radius: 99px; line-height: 1.4; }
.badge.ok { background: var(--primary-tint); color: var(--ok); }
.badge.off { background: #eeeeee; color: var(--muted); }
.badge.used { background: var(--danger-tint); color: var(--danger); }

.flash { background: var(--primary-tint); color: var(--ok); border: 1px solid rgba(149, 181, 7, .35);
         padding: .7rem 1rem; border-radius: var(--radius-btn); margin-bottom: 1.25rem; font-weight: 500; }
.error-box { background: var(--danger-tint); color: var(--danger); border: 1px solid rgba(208, 69, 0, .3);
             padding: .7rem 1rem; border-radius: var(--radius-btn); margin-bottom: 1rem; font-weight: 500; }

/* ================= Teilnehmer-Ansicht ================= */
.public-topbar {
  background: var(--sidenav-header); color: #fff; height: 64px;
  padding: 0 24px; display: flex; align-items: center; gap: .9rem;
}
.public-topbar .logo { height: 26px; width: auto; display: block; }
.public-topbar .brand { font-weight: 500; letter-spacing: .01em; color: rgba(255, 255, 255, .85);
                        padding-left: .9rem; border-left: 1px solid rgba(255, 255, 255, .2); }
/* width:100% ist wichtig: in der Flex-Spalte würde die Wrap sonst wegen margin:auto
   auf die Inhaltsbreite schrumpfen und die Kartenbreite je Frage springen. */
.public-wrap { width: 100%; max-width: 760px; margin: 2.5rem auto; padding: 0 1rem; }
.public-wrap.narrow { max-width: 460px; }

.hero-card { text-align: center; padding: 2.25rem 2rem; }
.hero-card p { color: var(--text); }

/* Teilnehmer-Ansicht: dunkler Hintergrund wie im Relution-Portal */
.public-body { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg-dark); }
.public-body .public-wrap { flex: 1 0 auto; }

/* Footer mit dauerhaft sichtbarem Impressum-Link */
.site-footer { flex: none; padding: 1.25rem 1.5rem; text-align: center;
               font-size: .82rem; color: var(--muted-light); }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary-dark); text-decoration: underline; }
/* auf dunklem Hintergrund (Teilnehmer) heller */
.public-body .site-footer { color: rgba(255, 255, 255, .45); }
.public-body .site-footer a { color: rgba(255, 255, 255, .65); }
.public-body .site-footer a:hover { color: #fff; }

/* Prüfungs-Karte: feste Mindesthöhe, Navigation unten – kein Größenspringen */
.exam-card { display: flex; flex-direction: column; min-height: 520px; }
.exam-card > form { flex: 1; display: flex; flex-direction: column; }
.exam-card .question { flex: 1 0 auto; border-bottom: 0; padding-top: 0; }
.exam-card .exam-nav { margin-top: auto; }

/* Optionales „Zertifikat per E-Mail"-Feld auf der Ergebnisseite */
.cert-mail-form { border-top: 1px solid var(--line-soft); padding-top: 1.25rem; }
.mail-row { display: flex; gap: .6rem; align-items: stretch; }
.mail-row input { flex: 1; }
.mail-row .btn { flex: none; white-space: nowrap; }

/* Prüfung */
.question { padding: 1.5rem 0; border-bottom: 1px solid var(--line-soft); }
.question:last-of-type { border-bottom: 0; }
.q-num { color: var(--primary-dark); font-weight: 700; font-size: .78rem; letter-spacing: .05em; }
.q-text { font-weight: 700; color: var(--text-strong); margin: .3rem 0 .85rem; font-size: 1rem;
          overflow-wrap: break-word; word-break: break-word; hyphens: auto; }
.option { display: flex; align-items: flex-start; gap: .65rem; padding: .6rem .8rem;
          border: 1px solid var(--line); border-radius: var(--radius-btn); margin-bottom: .55rem; cursor: pointer;
          transition: border-color .1s, background .1s; }
.option:hover { border-color: var(--primary); background: var(--primary-tint); }
.option input { margin-top: .15rem; flex: none; }
.option span { min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.option:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.hint { color: var(--muted-light); font-size: .82rem; }
.hint code, p code { font-family: ui-monospace, Consolas, monospace; background: #f4f4f4; padding: 0 .3em; border-radius: 2px; }

/* Prüfungs-Wizard: Fortschritt + Navigation */
.exam-progress { margin: 0 0 1.75rem; }
.exam-progress-head { display: flex; justify-content: space-between; align-items: baseline;
                      gap: 1rem; margin-bottom: .5rem; }
.exam-progress-head .q-num { color: var(--primary-dark); font-weight: 700; font-size: .85rem;
                             letter-spacing: .04em; }
.exam-bar { -webkit-appearance: none; -moz-appearance: none; appearance: none;
            display: block; width: 100%; height: 8px; border: 0; border-radius: 99px;
            background: var(--line-soft); overflow: hidden; }
.exam-bar::-webkit-progress-bar { background: var(--line-soft); border-radius: 99px; }
.exam-bar::-webkit-progress-value { background: var(--primary); border-radius: 99px; transition: width .2s ease; }
.exam-bar::-moz-progress-bar { background: var(--primary); border-radius: 99px; }
.exam-nav { display: flex; align-items: center; gap: .7rem; margin-top: 1.5rem;
            padding-top: 1.25rem; border-top: 1px solid var(--line-soft); }
.exam-nav .grow { flex: 1; }

.score-ring { font-size: 3rem; font-weight: 300; line-height: 1.1; margin-bottom: .5rem; }
.score-ring.pass { color: var(--primary); }
.score-ring.fail { color: var(--danger); }

/* ================= Admin-Layout ================= */
.admin { display: flex; min-height: 100vh; }
.sidebar {
  width: 270px; flex: none; background: var(--sidenav); color: var(--sidenav-item);
  display: flex; flex-direction: column;
}
.sidebar .brand { display: flex; align-items: center; height: 64px; padding: 0 20px;
                  background: var(--sidenav-header); }
.sidebar .brand .logo { height: 24px; width: auto; }
.sidebar nav { padding: .75rem 0; }
.sidebar nav a {
  display: block; color: var(--sidenav-item); padding: .7rem 24px; font-weight: 500;
  border-left: 3px solid transparent; transition: background .12s, color .12s;
}
.sidebar nav a:hover { color: #fff; background: var(--sidenav-hover); text-decoration: none; }
.sidebar nav a.active { color: #fff; background: var(--sidenav-hover); border-left-color: var(--primary); }
.sidebar .spacer { flex: 1; }
.sidebar form { padding: 1rem 24px; }
.sidebar .btn-logout { width: 100%; background: transparent; border: 1px solid rgba(255, 255, 255, .25);
                       color: var(--sidenav-item); box-shadow: none; font-weight: 500; }
.sidebar .btn-logout:hover { border-color: var(--primary); color: #fff; background: transparent; }

.content { flex: 1; padding: 2rem 2.5rem; max-width: 1160px; display: flex; flex-direction: column; }
.content-main { flex: 1 0 auto; }
.content .site-footer { text-align: left; padding: 1.5rem 0 0; }
@media (max-width: 800px) {
  .admin { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar .brand { padding: 0 16px; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0; }
  .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: .7rem 1rem; white-space: nowrap; }
  .sidebar nav a.active { border-bottom-color: var(--primary); }
  .sidebar .spacer { display: none; }
  .sidebar form { padding: .5rem 1rem; margin-left: auto; }
  .content { padding: 1.25rem; }
}

/* Dashboard-Kacheln */
.stat { text-align: center; padding: 1.5rem 1rem; }
.stat .num { font-size: 2.25rem; font-weight: 300; color: var(--primary); line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .82rem; font-weight: 500; margin-top: .3rem; }

.toolbar { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .grow { flex: 1; }

details.q-edit { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; background: #fff; }
details.q-edit summary { cursor: pointer; padding: .75rem .9rem; font-weight: 500; list-style: none; color: var(--text); }
details.q-edit summary::-webkit-details-marker { display: none; }
details.q-edit summary::before { content: "▸ "; color: var(--primary-dark); }
details.q-edit[open] summary::before { content: "▾ "; }
details.q-edit[open] summary { border-bottom: 1px solid var(--line); }
details.q-edit .inner { padding: 1rem .9rem; }
.opt-row { display: flex; gap: .6rem; align-items: center; margin-bottom: .45rem; }
.opt-row input[type=text] { flex: 1; }
.opt-row label.inline { display: flex; align-items: center; gap: .35rem; margin: 0;
                        font-size: .8rem; white-space: nowrap; color: var(--muted); font-weight: 500; }

/* ---------- Utility-Klassen (ersetzen CSP-verbotene Inline-Styles) ---------- */
.w-full { width: 100%; }
.block { display: block; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 1.25rem; }
.mt-sm { margin-top: .5rem; }
.m-0 { margin: 0; }
.align-end { align-self: flex-end; }
.inline-form { display: inline; }
.w-count { max-width: 120px; }
.gap-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .sidebar, .public-topbar { display: none; } }
