/* WERA Training — sea-chart palette: deep navy ink on a pale sea-foam ground,
   one radar-teal accent. The countdown is the single loud element. */
:root {
  --ink: #17293a;
  --navy: #0f3b5f;
  --navy-dark: #0a2a45;
  --teal: #17807e;
  --foam: #edf3f3;
  --line: #c9d8dc;
  --muted: #5b6d7a;
  --amber: #b97c00;
  --red: #b42318;

  --bs-body-font-family: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bs-body-color: var(--ink);
  --bs-link-color: var(--navy);
}

body {
  background: var(--foam);
  color: var(--ink);
  font-family: var(--bs-body-font-family);
  font-size: 1.0625rem;
  line-height: 1.55;
}

a { color: var(--navy); }
a:hover { color: var(--teal); }

h1, h2, h5, .section-title, .timer-value, .result-score-value, .error-code {
  font-family: "Barlow Semi Condensed", "Barlow", sans-serif;
}

/* ------------------------------------------------------------ sheet frame */
.sheet {
  max-width: 760px;
  margin: 2rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4rem);
}
.sheet-wide { max-width: 1240px; }

.sheet-header {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.logo-main { width: 84px; height: 84px; object-fit: contain; }
.header-title { text-align: center; }
.header-title h1 { font-size: 1.6rem; font-weight: 700; margin: 0; color: var(--navy); letter-spacing: .01em; }
.header-sub { margin: .25rem 0 0; color: var(--muted); font-size: 1rem; max-width: 46ch; margin-inline: auto; }
.header-aside { min-width: 84px; display: flex; justify-content: flex-end; }

.sheet-body { padding: 1.75rem 2rem; flex: 1; }

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.25rem 2rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .95rem;
}
.sheet-footer img { width: 56px; height: 56px; object-fit: contain; }

/* ------------------------------------------------------------- buttons */
.btn { font-weight: 500; }
.btn-primary { background: var(--navy); border-color: var(--navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-outline-primary { color: var(--navy); border-color: var(--navy); }
.btn-outline-primary:hover, .btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(23, 128, 126, .35);
  border-color: var(--teal);
}
.form-check-input:checked { background-color: var(--navy); border-color: var(--navy); }

.section-title { font-size: 1.2rem; font-weight: 600; color: var(--navy); margin-bottom: .75rem; }
.pre-line { white-space: pre-line; }

/* --------------------------------------------------------- login form */
.form-grid {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem 1.5rem;
  align-items: start;
}
.form-grid-label { padding-top: .45rem; font-weight: 500; }
.form-grid-full { grid-column: 1 / -1; margin-top: 1rem; }

.signature-wrap {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: 4px;
  background: #fff;
  height: 170px;
}
.signature-wrap:focus-within, .signature-wrap:hover { border-color: var(--teal); }
#signature-pad { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.signature-hint {
  position: absolute; inset: auto 0 .6rem; text-align: center;
  color: #a6b6be; pointer-events: none; font-size: .95rem;
}
.signature-hint::before {
  content: ""; display: block; width: 70%; margin: 0 auto .35rem; border-top: 1px solid #d6e1e4;
}

.duration-note { color: var(--muted); margin-bottom: 1rem; }
.btn-start { min-width: 14rem; }

.empty-state { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 4rem; font-weight: 700; color: var(--navy); margin: 0; line-height: 1; }

/* ---------------------------------------------------- timer (the star) */
.timer { text-align: right; line-height: 1.1; }
.timer-label { display: block; font-size: .85rem; color: var(--muted); }
.timer-value {
  font-size: 2.25rem; font-weight: 700; color: var(--navy);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.timer.is-low .timer-value { color: var(--amber); }
.timer.is-critical .timer-value { color: var(--red); animation: pulse 1s steps(2, start) infinite; }
@keyframes pulse { to { opacity: .55; } }

.time-bar { height: 4px; background: #dfe9eb; }
.time-bar span {
  display: block; height: 100%; background: var(--teal);
  transform-origin: left center; transition: transform .25s linear, background-color .3s;
}
.is-quiz:has(.timer.is-low) .time-bar span { background: var(--amber); }
.is-quiz:has(.timer.is-critical) .time-bar span { background: var(--red); }

.is-quiz .sheet-header { position: sticky; top: 0; background: #fff; z-index: 10; border-radius: 6px 6px 0 0; }

/* ------------------------------------------------------------- steps */
.steps { display: flex; border-bottom: 1px solid var(--line); }
.step {
  flex: 1; border: 0; background: none; padding: .8rem 1rem; color: var(--muted);
  font-weight: 500; border-bottom: 3px solid transparent; display: flex; align-items: center;
  justify-content: center; gap: .5rem;
}
.step.is-current { color: var(--navy); border-bottom-color: var(--navy); }
.step-num {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1.5px solid currentColor;
  display: inline-grid; place-items: center; font-size: .85rem;
}
.step-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

/* --------------------------------------------------------- questions */
.instructions, .assessment {
  border-left: 3px solid var(--teal); background: #f5f9f9; padding: 1rem 1.25rem; margin-bottom: 1.75rem;
}
.question { border-top: 1px solid var(--line); padding: 1.4rem 0 1.2rem; margin: 0; min-width: 0; }
.question-subtitle { font-size: 1.1rem; font-weight: 600; float: none; margin-bottom: .35rem; }
.question-detail { color: var(--ink); margin-bottom: .85rem; max-width: 70ch; }

.answer-list { display: grid; gap: .35rem; }
.answer {
  display: flex; align-items: flex-start; gap: .75rem; padding: .55rem .75rem;
  border: 1px solid transparent; border-radius: 4px; cursor: pointer;
}
.answer .form-check-input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex-shrink: 0; }
.answer:hover { background: #f3f7f8; }
.answer:has(input:checked) { background: #e7f0f6; border-color: #b8cfdf; }

.scale { display: flex; flex-wrap: wrap; gap: .5rem; }
.scale-option .btn { min-width: 7.5rem; }

.step-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .75rem;
  border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: .5rem;
}
.save-status { margin-right: auto; color: var(--muted); font-size: .9rem; }
.save-status.is-error { color: var(--red); }

/* ------------------------------------------------------------- result */
.result { max-width: 30rem; margin: 0 auto; }
.result-score { text-align: center; margin-bottom: 2rem; }
.result-score-value { font-size: 4.5rem; font-weight: 700; color: var(--navy); line-height: 1; }
.result-score-max { font-size: 1.6rem; color: var(--muted); font-family: "Barlow Semi Condensed", sans-serif; }
.result-score-note { color: var(--muted); margin: .4rem 0 0; }

.result-list { display: grid; grid-template-columns: 10rem 1fr; gap: .6rem 1rem; margin: 0; }
.result-list dt { font-weight: 500; color: var(--muted); }
.result-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-list-compact { grid-template-columns: 9rem 1fr; }

/* ------------------------------------------------------------- admin */
.admin-nav { display: flex; align-items: center; gap: .75rem; }
.admin-login { max-width: 22rem; margin: 1rem auto; }
.admin-section { margin-bottom: 3rem; }
.filters .form-select, .filters .form-control { width: auto; min-width: 12rem; }

table.dataTable thead th { color: var(--navy); font-weight: 600; border-bottom-color: var(--navy) !important; white-space: nowrap; }
.page-item.active .page-link { background-color: var(--navy); border-color: var(--navy); }
.page-link { color: var(--navy); }

.badge.bg-success-subtle { background: #dcefe9 !important; color: #10594f; font-weight: 500; }
.badge.bg-secondary-subtle { background: #e6ebee !important; color: var(--muted); font-weight: 500; }

.text-truncate-3 {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 28rem;
}
.answer-summary { list-style: none; padding: 0; margin: 0; font-size: .95rem; }
.answer-summary li { padding-left: 1.3rem; position: relative; }
.answer-summary li.is-correct { color: var(--teal); font-weight: 600; }
.answer-summary li.is-correct i { position: absolute; left: 0; top: .1rem; }

.type-tag { font-size: .85rem; padding: .15rem .55rem; border-radius: 3px; font-weight: 500; }
.type-quiz { background: #e2ecf4; color: var(--navy); }
.type-evaluation { background: #e3f1ef; color: #10594f; }

.option-editor { display: grid; gap: .5rem; }
.option-row { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; }
.option-row .option-correct { width: 1.25rem; height: 1.25rem; margin: 0; }
.option-editor.is-evaluation .option-correct { visibility: hidden; }

/* ------------------------------------------------------------- report */
.report-top { display: grid; grid-template-columns: 1fr 15rem; gap: 2rem; align-items: start; }
.report-signature { margin: 0; text-align: center; }
.report-signature img { width: 100%; border-bottom: 1px solid var(--ink); }
.report-signature figcaption { font-size: .9rem; color: var(--muted); margin-top: .3rem; }
.report-table th { color: var(--navy); }

@media print {
  body { background: #fff; font-size: 11pt; }
  .sheet { margin: 0; border: 0; min-height: 0; max-width: none; }
  .no-print, .alert { display: none !important; }
  .sheet-footer { break-inside: avoid; }
}

/* ------------------------------------------------------------- mobile */
@media (max-width: 640px) {
  .sheet { margin: 0; border: 0; border-radius: 0; min-height: 100vh; }
  .sheet-header { grid-template-columns: 52px 1fr auto; padding: 1rem; gap: .75rem; }
  .logo-main { width: 52px; height: 52px; }
  .header-title h1 { font-size: 1.15rem; }
  .header-sub { font-size: .85rem; }
  .header-aside { min-width: 0; }
  .timer-value { font-size: 1.6rem; }
  .sheet-body { padding: 1.25rem 1rem; }
  .form-grid { grid-template-columns: 1fr; gap: .35rem; }
  .form-grid-label { padding-top: .6rem; }
  .result-list { grid-template-columns: 8rem 1fr; }
  .report-top { grid-template-columns: 1fr; }
  .step { font-size: .9rem; padding: .7rem .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .timer.is-critical .timer-value { animation: none; }
  .time-bar span { transition: none; }
}

/* ------------------------------------------- v2: generate buttons, mail */
.admin-section + .admin-section { border-top: 1px solid var(--line); padding-top: 1.75rem; }

.btn-gen {
  width: 2rem; padding-left: 0; padding-right: 0; font-weight: 600;
  font-family: "Barlow Semi Condensed", sans-serif; border-width: 1px;
}
.btn-gen-p { background: #dcefd9; border-color: #7fae6f; color: #2f5d24; }
.btn-gen-p:hover { background: #c4e2bf; color: #24481b; border-color: #5f9450; }
.btn-gen-c { background: #f9d7d5; border-color: #c4645e; color: #8a2a24; }
.btn-gen-c:hover { background: #f2bdb9; color: #6f211c; border-color: #a94c46; }

.mail-status { color: var(--muted); padding: 0 .25rem; font-size: 1.1rem; vertical-align: middle; }
.mail-status.is-sent { color: var(--teal); }
.mail-status.is-failed { color: var(--red); }

.certificate-note {
  text-align: center; color: var(--muted); font-size: .95rem; margin: 1.5rem auto 0; max-width: 32rem;
}
