/* frontend/style.css */

/* ── Skip-to-content link (accessibility) ───────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 8px;
}

:root {
  --maxw: 1180px;
  --gap: 16px;

  --bg: #f6f2ea;
  --panel: #ffffff;
  --panel2: #fbf8f1;
  --border: rgba(31, 41, 55, 0.14);
  --text: #111827;
  --muted: rgba(17, 24, 39, 0.75);

  --accent: #2f5f4f;
  --accent2: #1f4d3f;
  --accentSoft: rgba(47, 95, 79, 0.12);

  --danger: #991b1b;
  --warn: #b45309;

  --dangerBg: #fff1f1;
  --warnBg: #fff7ed;
  --okBg: #f0fdf4;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

.muted {
  color: var(--muted);
}

/* Header */
.clinicbar {
  background: var(--panel);
  border-bottom: 1px solid rgba(31, 41, 55, 0.12);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.clinicbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.clinic-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.clinic-sub {
  margin-top: 2px;
  font-size: 0.95rem;
  color: rgba(31, 41, 55, 0.62);
}

.demo-banner {
  flex: 1 1 auto;
  text-align: center;
  color: rgba(120, 53, 15, 0.85);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  padding: 0 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 55, 0.14);
  background: rgba(255, 255, 255, 0.75);
  color: rgba(31, 41, 55, 0.78);
  font-size: 0.95rem;
  white-space: nowrap;
}

.pill-ok {
  color: var(--accent2);
  border-color: rgba(47, 95, 79, 0.25);
  background: var(--okBg);
}

.pill-bad {
  color: var(--danger);
  border-color: rgba(153, 27, 27, 0.25);
  background: var(--dangerBg);
}

/* App frame */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 12px 12px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);

  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 10px 10px 0;
  flex: 0 0 auto;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.form {
  padding: 8px 10px 10px;
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

@media (min-width: 1041px) {
  .panel-output {
    position: sticky;
    top: 72px; /* ca. høyden på header */
    max-height: calc(100vh - 72px - 18px);
  }

  .panel-output #results,
  .panel-output #empty,
  .panel-output #loading,
  .panel-output #error {
   overflow: auto;
   flex: 1 1 auto;
   min-height: 0;
  }
}

/* Form */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
}

@media (max-width: 540px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.field {
  margin-top: 8px;
}

.field-symptom {
  background: var(--accentSoft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(47, 95, 79, 0.55);
  box-shadow: 0 0 0 4px var(--accentSoft);
}

textarea[readonly] {
  background: var(--panel2);
  cursor: default;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
}

/* Inline clearable input wrapper */
.input-clearable {
  position: relative;
}

.input-clearable input {
  padding-right: 32px;
}

.btn-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 50%;
  transition: color 0.12s, background 0.12s;
}

.btn-clear:hover {
  color: var(--danger);
  background: rgba(153, 27, 27, 0.08);
}

/* Unified medication container */
.field-meds {
  margin-top: 10px;
}

.med-count {
  font-weight: 400;
  font-size: 0.88rem;
  margin-left: 4px;
}

.med-container {
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.med-container:focus-within {
  border-color: rgba(47, 95, 79, 0.55);
  box-shadow: 0 0 0 4px var(--accentSoft);
}

.med-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.med-chips:not(:empty) {
  margin-bottom: 8px;
}

.med-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.med-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  border: none;
  padding: 6px 4px;
  border-radius: 8px;
  outline: none;
  background: transparent;
  box-shadow: none;
}

.med-input-row input:focus {
  border-color: transparent;
  box-shadow: none;
}

/* Details / advanced */
.advanced {
  margin-top: 12px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(251, 248, 241, 0.7);
}

.advanced > summary {
  cursor: pointer;
  font-weight: 700;
}

.fieldset {
  margin-top: 12px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.check input {
  transform: translateY(1px);
}

/* Buttons */
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > input[type="text"],
.row > input[type="number"],
.row > input:not([type]) {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.row-between {
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions-primary {
  margin-top: 14px;
}

.btn {
  border: 1px solid rgba(17, 24, 39, 0.18);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}

.btn:hover {
  filter: brightness(0.985);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: rgba(47, 95, 79, 0.4);
}

.btn-primary:hover {
  filter: brightness(0.98);
}

/* Match demo-knappens størrelse/shape for "Kjør vurdering" */
.btn-run {
  width: 100%;
  padding: 9px 12px;     /* samme som .btn-demo */
  border-radius: 10px;   /* samme som .btn-demo */
  display: flex;
  align-items: center;
  justify-content: center;
}


.btn-small {
  padding: 8px 10px;
  border-radius: 11px;
  font-size: 0.95rem;
}

/* Output blocks */
.error {
  margin: 12px 14px 0;
  border: 1px solid rgba(153, 27, 27, 0.25);
  background: var(--dangerBg);
  border-radius: 14px;
  padding: 12px;
}

.error-title {
  font-weight: 800;
}

.error-msg {
  margin-top: 6px;
}

.error-details {
  margin-top: 8px;
}

.error pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: #fff;
  overflow: auto;
}


.empty {
  margin: 12px 14px 14px;
  border: 1px dashed rgba(17, 24, 39, 0.2);
  border-radius: 14px;
  padding: 14px;
  background: rgba(251, 248, 241, 0.6);
}

.empty-title {
  font-weight: 800;
}

.empty-text {
  color: var(--muted);
  margin-top: 6px;
}

/* Summary */
.summary {
  padding: 14px 18px 12px;
  background: rgba(47, 95, 79, 0.04);
  border-bottom: 1px solid var(--border);
}

.summary-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: rgba(255, 255, 255, 0.8);
  color: rgba(17, 24, 39, 0.78);
  font-size: 0.92rem;
}

.chip-strong {
  border-color: rgba(47, 95, 79, 0.25);
  background: rgba(47, 95, 79, 0.08);
  color: rgba(17, 24, 39, 0.9);
  font-weight: 700;
}

.chip-unrecognized {
  border-color: rgba(180, 130, 0, 0.35);
  background: rgba(255, 200, 0, 0.10);
  color: rgba(17, 24, 39, 0.75);
}

/* Cards */
.card {
  margin: 12px 14px 0;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 14px;
  background: #fff;
}

.card-body {
  padding: 12px;
  margin-top: -4px;
}

#note {
  width: 100%;
  border-radius: 14px;
}

/* Footer */
.footer {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.btn-feedback {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-feedback:hover {
  color: var(--text);
  border-color: var(--text-muted);
}


/* ── Symptom-chips klikkliste ─────────────────────────── */
.symptom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip-clickable {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  transition: background 0.12s, border-color 0.12s;
}

.chip-clickable:hover {
  background: var(--accentSoft);
  border-color: var(--accent);
}

.chip-active {
  background: var(--accentSoft);
  border-color: var(--accent);
  color: var(--accent2);
  font-weight: 600;
}

/* ── Severity badges ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-high     { background: #fecaca; color: #991b1b; }
.badge-moderate { background: #fef3c7; color: #92400e; }
.badge-low      { background: #dcfce7; color: #166534; }
.badge-muted    { background: #f3f4f6; color: #6b7280; }

/* ── Card-headers – tydeligere overskrifter ───────────── */
.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

.card-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Økt spacing inne i vurderingskort ───────────────── */
.card-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.item {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  font-weight: 700;
  font-size: 1.0rem;
  line-height: 1.3;
}

.item-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-high     { border-left: 3.5px solid #dc2626; background: #fef2f2; }
.item-moderate { border-left: 3.5px solid #d97706; background: #fffbeb; }
.item-low      { border-left: 3.5px solid #16a34a; }

.item-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px;
  font-size: 0.92rem;
}

.kv .k {
  font-weight: 600;
  color: var(--muted);
}

.item-high .kv .v {
  font-weight: 600;
}

/* ── Action callout for HØY items ───────────────────── */
.item-action-callout {
  font-size: 0.9rem;
  font-weight: 600;
  color: #991b1b;
  padding: 7px 10px;
  background: rgba(153, 27, 27, 0.07);
  border-radius: 6px;
  line-height: 1.4;
}


.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 4px 10px;
}

.btn-ghost:hover {
  background: var(--accentSoft);
  border-color: var(--accent);
  color: var(--accent2);
}

/* ── Kausalitet-kort (kollapsibel) ──────────────────────────────── */
.card-causal {
  border-left: 3px solid var(--accent);
}

details.card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.card > summary::-webkit-details-marker {
  display: none;
}
details.card > summary::after {
  content: "▸ Vis";
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
details[open].card > summary::after {
  content: "▾ Skjul";
}

.card-header-causal {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Note card sits below the input panel in the left column */
#note-section {
  margin-top: 1.5rem;
}

.causal-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent2);
  background: var(--accentSoft);
  border: 1px solid rgba(47, 95, 79, 0.2);
  border-radius: 999px;
  padding: 2px 9px;
}

#causality-lead {
  font-size: 0.93rem;
  margin-bottom: 10px;
}

.bullets {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bullets li {
  margin: 6px 0;
  font-size: 0.93rem;
  line-height: 1.5;
}


/* ── Logout button in header ─────────────────────────────── */
.btn-logout {
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-logout:hover {
  border-color: var(--accent);
  color: var(--accent);
}


/* ── Causation verdict banner ────────────────────────────── */
.causation-verdict { padding: 12px; border-radius: 6px; margin-bottom: 12px; }
.causation-verdict.verdict-known { background: #fff4e5; border-left: 4px solid #e69500; }
.causation-verdict.verdict-unknown { background: #eef6ff; border-left: 4px solid #3377cc; }
.causation-verdict strong { display: block; margin-bottom: 4px; }
.causation-verdict p { margin: 4px 0; }
