/* ============================================================================
   komponenter.css — nøytralt komponentsett bygget KUN på tokens.css.
   Rør aldri farger/radius her; endre dem i tokens.css så slår de gjennom overalt.
   ============================================================================ */

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 var(--space-4); }
code, kbd, pre { font-family: var(--font-mono); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Knapper ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font: inherit; font-weight: 600; line-height: 1;
  padding: 10px 18px; border-radius: var(--radius-md);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: .875rem; }

/* ── Skjema ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--space-4); }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: var(--space-2); }
.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"], input[type="url"],
input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}
textarea { min-height: 7rem; resize: vertical; }
.field-hint { display: block; margin-top: var(--space-2); font-size: .85rem; color: var(--text-subtle); }
.field-error .input, .field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }
.field-error-text { display: block; margin-top: var(--space-2); font-size: .85rem; color: var(--danger); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: .95rem; }
.check input { width: auto; }

/* ── Kort ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm);
}
.card-title { margin-bottom: var(--space-3); }
.card + .card { margin-top: var(--space-4); }

/* ── Tabell ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { font-weight: 650; color: var(--text); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }

/* ── Varsler ────────────────────────────────────────────────────────────── */
.alert {
  border: 1px solid var(--border-strong); border-left-width: 4px;
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
}
.alert-success { background: var(--success-bg); border-left-color: var(--success); }
.alert-warning { background: var(--warning-bg); border-left-color: var(--warning); }
.alert-danger  { background: var(--danger-bg);  border-left-color: var(--danger); }
.alert-info    { background: var(--info-bg);    border-left-color: var(--info); }

/* ── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: transparent; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 700; font-size: 1.05rem; }
.topbar-nav { display: flex; align-items: center; gap: var(--space-4); }
.topbar-nav a { color: var(--text-muted); }
.topbar-nav a:hover { color: var(--text); }

/* ── Modal (native <dialog>) ────────────────────────────────────────────── */
.modal {
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  padding: var(--space-5); max-width: 32rem; width: calc(100% - 2rem); box-shadow: var(--shadow-md);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

/* ── Paginering ─────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: var(--space-2); list-style: none; padding: 0; margin: var(--space-4) 0 0; }
.pagination a, .pagination span {
  display: inline-block; padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--text-muted); background: var(--surface);
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .is-active { background: var(--brand); color: var(--brand-contrast); border-color: transparent; }
