/* Spørgeskema – samlet stylesheet */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --row-done: #dde1e8;
  --text: #1c2430;
  --muted: #5d6878;
  --border: #dde1e7;
  --primary: #2f5bd3;
  --primary-hover: #2449ad;
  --primary-soft: #e6edfc;
  --success: #1d7a4b;
  --success-soft: #e3f4ea;
  --danger: #c0352b;
  --danger-soft: #fbe8e6;
  --warning-soft: #fdf3dc;
  --warning-text: #7a5300;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  --focus: 0 0 0 3px rgb(47 91 211 / 0.35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --surface-2: #232a34;
    --row-done: #0f1318;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --border: #2f3844;
    --primary: #6d93f2;
    --primary-hover: #8eabf5;
    --primary-soft: #23304d;
    --success: #5ccf91;
    --success-soft: #183327;
    --danger: #f07b71;
    --danger-soft: #3a2020;
    --warning-soft: #3a3016;
    --warning-text: #f0cf7a;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
code, .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 2rem; padding-bottom: 4rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.35rem 0 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff; font-weight: 800;
}
.site-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-nav a { text-decoration: none; }
.site-nav form { margin: 0; }

/* Cards & layout */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.stack > * + * { margin-top: 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.page-actions form { margin: 0; }
.breadcrumb { margin: 0 0 0.25rem; font-size: 0.9rem; }
.breadcrumb a { text-decoration: none; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.section-head h2 { margin: 0; }

.hero { max-width: 560px; margin: 2rem auto 1rem; text-align: center; padding: 2.5rem 1.5rem; }
.lead { font-size: 1.05rem; color: var(--muted); }
.auth-card { max-width: 420px; margin: 1rem auto; }
.answer-card { max-width: 720px; margin: 0 auto; }
.empty-state { text-align: center; padding: 3rem 1.5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.6rem 1rem; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text);
}
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .icon-btn:focus-visible {
  outline: none; box-shadow: var(--focus);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-link { background: none; border: none; color: var(--muted); text-decoration: underline; font-weight: 400; padding-left: 0; padding-right: 0; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn-lg { padding: 0.8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.text-danger { color: var(--danger); }
.text-danger:hover { background: var(--danger-soft); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-narrow { max-width: 260px; }
.field-row { display: flex; align-items: flex-end; gap: 1.25rem; flex-wrap: wrap; margin-top: 0.75rem; }
label { font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 0.6rem 0.75rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.6; }
.input-narrow { width: 90px; }
.input-sm { padding: 0.35rem 0.55rem; font-size: 0.9rem; }
.checkbox { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 500; margin-top: 0.6rem; }
.checkbox input { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }
.field-error { color: var(--danger); font-size: 0.875rem; margin: 0.25rem 0 0; font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* Alerts & badges */
.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.badge-open { background: var(--success-soft); color: var(--success); }
.badge-closed { background: var(--danger-soft); color: var(--danger); }

/* Offentlig header: kun en lille admin-knap i øverste højre hjørne */
.public-header { display: flex; justify-content: flex-end; padding: 12px 16px; min-height: 52px; }
.admin-login {
  font-size: 0.8rem; font-weight: 600; color: var(--muted); text-decoration: none;
  padding: 0.3rem 0.75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.admin-login:hover { color: var(--text); border-color: var(--muted); }

/* Firmalogo som svagt vandmærke i baggrunden på alle sider */
.watermark {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  display: grid; place-items: center; padding: 16px;
}
.watermark img { width: min(92vw, 1100px); height: auto; opacity: 0.08; user-select: none; }
@media (prefers-color-scheme: dark) {
  /* Sort tekst bliver hvid, rød forbliver rød. */
  .watermark img { filter: invert(1) hue-rotate(180deg); opacity: 0.1; }
}

.success-mark {
  width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--success-soft); color: var(--success); font-size: 2rem; font-weight: 800;
}

/* Answer form */
.anon-note { background: var(--primary-soft); border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.92rem; }
.step-progress { color: var(--muted); font-size: 0.9rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }
.step-actions .step-forward { margin-left: auto; }
.answer-card .button_to { margin-top: 1rem; }
.question { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin: 0 0 1rem; }
.question-label { display: block; font-weight: 700; font-size: 1.02rem; margin-bottom: 0.5rem; }
.question.has-error { border-color: var(--danger); background: var(--danger-soft); }
.question-number { color: var(--muted); }
.req { color: var(--danger); margin-left: 0.15rem; }

/* Survey list */
.survey-list { list-style: none; margin: 0; padding: 0; }
.survey-item { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; color: var(--text); text-decoration: none; flex-wrap: wrap; }
.survey-item:hover { border-color: var(--primary); color: var(--text); }
.survey-item h2 { margin: 0 0 0.25rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.survey-item p { margin: 0; }
.survey-item-progress { min-width: 200px; flex: 0 1 260px; }
.survey-item-progress p { margin-bottom: 0.35rem; }

/* Progress */
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); border-radius: 999px; transition: width 0.3s; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.progress-numbers { font-size: 1.15rem; margin: 0 0 0.6rem; }
.progress-numbers strong { font-size: 1.8rem; }
.progress-status { margin: 0; color: var(--muted); }
.progress-card .hint { margin-top: 0.75rem; }

/* Question builder */
.question-list { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.question-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface-2); }
.question-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; gap: 0.5rem; }
.question-card-tools { display: flex; gap: 0.25rem; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px;
  min-width: 34px; height: 32px; padding: 0 0.5rem; cursor: pointer; font: inherit; font-size: 0.85rem;
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger-soft); }

/* Codes table */
.table-wrap { overflow-x: auto; margin: 0.75rem 0 1rem; }
.codes-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.codes-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.codes-table th, .codes-table td { padding: 0.5rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.codes-table .code { font-size: 1rem; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; }
/* Afkrydsning ude til højre. Afkrydset række bliver mørkere, og linket streges over. */
.codes-table .sent-cell { width: 1%; text-align: right; }
.sent-checkbox { width: 1.25rem; height: 1.25rem; margin: 0; vertical-align: middle; cursor: pointer; accent-color: var(--primary); }
.codes-table tbody tr:has(.sent-checkbox:checked) { background: var(--row-done); }
.codes-table tbody tr:has(.sent-checkbox:checked) .code { text-decoration: line-through; color: var(--muted); }
.codes-table .code-name { font-weight: 600; overflow-wrap: break-word; }
/* Lange links må brydes hvor som helst, så tabellen også passer på mobil. */
.codes-table .invite-link { font-size: 0.85rem; font-weight: 500; letter-spacing: 0; white-space: normal; overflow-wrap: anywhere; }
.codes-table tbody tr:has(.sent-checkbox:checked) .code-name { color: var(--muted); }
.codes-table .row-actions { text-align: right; white-space: nowrap; width: 1%; }

/* Results */
.result { padding: 1rem 0; border-top: 1px solid var(--border); }
.result:first-of-type { border-top: none; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem 1rem; flex-wrap: wrap; }
.result h3 { margin: 0; }
.result-count { margin: 0; color: var(--muted); white-space: nowrap; }
.result-count strong { color: var(--text); }
.text-answers { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.text-answer {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  background: var(--surface-2); border-radius: 8px; padding: 0.55rem 0.5rem 0.55rem 0.8rem;
}
.text-answer-body { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 0.2rem; }
.text-answer .btn { flex-shrink: 0; }

@media (max-width: 600px) {
  h1 { font-size: 1.45rem; }
  .card { padding: 1.1rem; }
  /* På mobil vises kun /s/… af linket; "Kopiér link" kopierer stadig hele linket. */
  .codes-table .link-host { display: none; }
}

@media print {
  .site-header, .public-header, .page-actions, .row-actions { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
