/* Nærvær – felles designsystem for admin, mobil og TV. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef1f4;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #e6f4f2;
  --on-brand: #ffffff;

  --success: #15803d;
  --success-soft: #e7f6ec;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fdf3e1;
  --info: #1d4ed8;
  --info-soft: #e8effd;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, .18);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1016;
    --surface: #121922;
    --surface-2: #161e28;
    --surface-3: #1c2531;
    --text: #e6ebf1;
    --text-2: #c3ccd7;
    --muted: #8b97a6;
    --border: #243040;
    --border-strong: #334155;
    --brand: #2bb3a3;
    --brand-strong: #5cc9bb;
    --brand-soft: #0f2e2b;
    --on-brand: #04201d;
    --success: #4ade80;
    --success-soft: #0f2a1a;
    --danger: #f87171;
    --danger-strong: #fca5a5;
    --danger-soft: #2d1414;
    --warning: #fbbf24;
    --warning-soft: #2c2210;
    --info: #7aa2ff;
    --info-soft: #141f38;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand); }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Ikoner */
.icon { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.2em; }
.icon svg { width: 100%; height: 100%; display: block; }

/* Knapper */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 38px;
  padding: 0 14px;
  font: 500 14px/1 var(--font);
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 92%, var(--text)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { --btn-bg: var(--brand); --btn-fg: var(--on-brand); --btn-border: var(--brand); }
.btn.primary:hover { --btn-bg: var(--brand-strong); }
.btn.success { --btn-bg: var(--success); --btn-fg: #fff; --btn-border: var(--success); }
.btn.danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn.danger-ghost { --btn-fg: var(--danger); --btn-border: transparent; --btn-bg: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { min-height: 48px; padding: 0 20px; font-size: 16px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn.icon-only { padding: 0; width: 38px; }
.btn.sm.icon-only { width: 30px; }

/* Skjema */
.field { display: grid; gap: 6px; align-content: start; }
.field > span, .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  font: 14px/1.4 var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 80px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input.mono { font-family: var(--mono); letter-spacing: .02em; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .form-grid.two { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-size: 13px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--focus); outline: none; }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* Kort, merker, avatarer */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }

.badge {
  --b-fg: var(--text-2);
  --b-bg: var(--surface-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  color: var(--b-fg);
  background: var(--b-bg);
  white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { --b-fg: var(--success); --b-bg: var(--success-soft); }
.badge.danger { --b-fg: var(--danger); --b-bg: var(--danger-soft); }
.badge.warning { --b-fg: var(--warning); --b-bg: var(--warning-soft); }
.badge.info { --b-fg: var(--info); --b-bg: var(--info-soft); }
.badge.brand { --b-fg: var(--brand); --b-bg: var(--brand-soft); }
.badge.pulse::before { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.avatar {
  --size: 40px;
  --c: #64748b;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-weight: 600;
  font-size: calc(var(--size) * .38);
  letter-spacing: .02em;
  position: relative;
  user-select: none;
}
.avatar.sm { --size: 30px; }
.avatar.lg { --size: 56px; }
.avatar.xl { --size: 96px; }
.avatar .presence {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--muted);
}
.avatar .presence.on { background: #22c55e; }

/* Toast */
.toasts { position: fixed; z-index: 1000; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #1e293b;
  color: #f8fafc;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in .2s ease-out;
  pointer-events: auto;
}
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialog */
dialog.modal {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; opacity: .5; margin-bottom: 8px; }

/* Oppsettsiden bruker disse */
.page-narrow { max-width: 680px; margin: 0 auto; padding: 32px 16px 48px; }
