/* ============================================================
   Univia Mail Intelligence — componentlaag (UMI)
   Bouwt op het Univia Design System (kleuren, Syne/Inter,
   4px-spacing, capsule-radii). Framework-onafhankelijk: één
   stylesheet die 1-op-1 naar Django static/ kan.
   ============================================================ */

:root {
  /* Univia palet */
  --radiant-royal: #6851eb;
  --radiant-royal-80: #8371ec;
  --radiant-royal-60: #b8b1f1;
  --radiant-royal-40: #d3d1f4;
  --royal-8: #f0eefd; /* afgeleide tint: geselecteerde keuzes */
  --midnight-blue: #2b246f;
  --night: #070a26;
  --night-80: #353850;
  --night-60: #9295a3;
  --night-40: #c0c3cc;
  --white: #ffffff;
  --silver-phoenix: #eaeef4;
  --paper-white: #eef1f6;
  --heart-of-ice: #f8fbfd;

  /* Semantiek */
  --fg-1: var(--night);
  --fg-2: var(--night-80);
  --fg-3: #5c6075; /* AA-variant van Night 60 voor kleine tekst */
  --fg-4: var(--night-60); /* alleen decoratief / placeholders */
  --fg-accent: var(--radiant-royal);
  --fg-accent-deep: var(--midnight-blue);
  --bg-page: var(--paper-white);
  --bg-panel: var(--heart-of-ice);
  --bg-muted: var(--silver-phoenix);
  --bg-field: var(--white);
  --line: #e2e7ef; /* scheidingslijn op Heart of Ice */
  --line-strong: var(--night-40);

  /* Statuskleuren (toevoeging; altijd met icoon + tekst) */
  --ok-fg: #17603f;
  --ok-bg: #e2f2ea;
  --warn-fg: #7f4b00;
  --warn-bg: #fbefd9;
  --err-fg: #a61d31;
  --err-bg: #fbe6e9;
  --info-fg: var(--midnight-blue);
  --info-bg: #e9e7fb;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(7, 10, 38, 0.06);
  --shadow-md: 0 6px 18px rgba(7, 10, 38, 0.08);
  --shadow-lg: 0 18px 48px rgba(7, 10, 38, 0.12);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --font-display: "Syne", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.umi {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
.umi *,
.umi *::before,
.umi *::after {
  box-sizing: border-box;
}
.umi h1,
.umi h2,
.umi h3,
.umi h4,
.umi p {
  margin: 0;
}
.umi button,
.umi input,
.umi select,
.umi textarea {
  font: inherit;
  color: inherit;
}

/* Typografie */
.t-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.t-h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.t-h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.3;
}
.t-h4 {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
}
.t-body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg-2);
}
.t-sm {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-2);
}
.t-xs {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--fg-3);
}
.t-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-accent);
}
.t-mono {
  font-family: var(--font-mono);
  font-size: 13px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 18px;
  color: var(--night);
}

/* Iconen (Lucide-stijl, 1.75 lijn) */
.i {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-sm {
  width: 16px;
  height: 16px;
}
.i-lg {
  width: 24px;
  height: 24px;
}

/* Focus */
.umi :focus-visible {
  outline: 3px solid var(--radiant-royal);
  outline-offset: 2px;
}
.is-focus {
  outline: 3px solid var(--radiant-royal) !important;
  outline-offset: 2px;
}

/* Knoppen — altijd capsule */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  border: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn:active {
  transform: scale(0.98);
}
.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
}
.btn-primary {
  background: var(--radiant-royal);
  color: var(--white);
}
.btn-primary:hover,
.btn-primary.is-hover {
  background: var(--midnight-blue);
  color: var(--white);
}
.btn-secondary {
  background: transparent;
  color: var(--fg-1);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-secondary:hover,
.btn-secondary.is-hover {
  color: var(--midnight-blue);
  box-shadow: inset 0 0 0 1px var(--midnight-blue);
  background: var(--white);
}
.btn-ghost {
  background: transparent;
  color: var(--fg-accent);
}
.btn-ghost:hover,
.btn-ghost.is-hover {
  background: var(--silver-phoenix);
  color: var(--midnight-blue);
}
.btn-dark {
  background: var(--night);
  color: var(--white);
}
.btn-dark:hover,
.btn-dark.is-hover {
  background: var(--night-80);
}
.btn-danger {
  background: transparent;
  color: var(--err-fg);
  box-shadow: inset 0 0 0 1px var(--err-fg);
}
.btn-danger:hover,
.btn-danger.is-hover {
  background: var(--err-bg);
}
.btn[disabled],
.btn.is-disabled {
  background: var(--silver-phoenix);
  color: var(--fg-3);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
.btn.is-loading {
  cursor: progress;
}
.btn .spin,
.spin {
  animation: umi-spin 900ms linear infinite;
}
.btn-icon {
  width: 44px;
  padding: 0;
}
.btn-icon.btn-sm {
  width: 36px;
}
@keyframes umi-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Links */
.umi a.link,
.link {
  color: var(--fg-accent);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.link:hover {
  color: var(--midnight-blue);
  text-decoration: underline;
}

/* Velden */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-1);
}
.hint {
  font-size: 12.5px;
  color: var(--fg-3);
  line-height: 1.45;
}
.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg-field);
  border: 0;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--fg-1);
  font-size: 14.5px;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.input,
.select {
  height: 44px;
  border-radius: var(--radius-pill);
  padding: 0 18px;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
}
.select-wrap {
  position: relative;
  display: block;
}
.select-wrap .i {
  position: absolute;
  right: 14px;
  top: 12px;
  pointer-events: none;
  color: var(--fg-2);
}
.textarea {
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--fg-3);
}
.input:focus,
.select:focus,
.textarea:focus,
.input.is-focus,
.textarea.is-focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--radiant-royal);
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.is-invalid {
  box-shadow: inset 0 0 0 2px var(--err-fg) !important;
}
.input[disabled],
.select[disabled],
.textarea[disabled] {
  background: var(--silver-phoenix);
  color: var(--fg-3);
  box-shadow: inset 0 0 0 1px var(--silver-phoenix);
  cursor: not-allowed;
}
.field-error {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: 13px;
  font-weight: 500;
  color: var(--err-fg);
}
.counter {
  font-size: 12.5px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

/* Stepper (aantal werkdagen) */
.stepper {
  display: inline-flex;
  align-items: center;
  height: 44px;
  border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  background: var(--bg-field);
  padding: 0 4px;
}
.stepper input {
  width: 52px;
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  height: 40px;
}
.stepper input:focus {
  outline: none;
}
.stepper:focus-within {
  box-shadow: inset 0 0 0 2px var(--radiant-royal);
}
.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
}
.stepper button:hover {
  background: var(--silver-phoenix);
}

/* Schakelaar: <button role="switch" aria-checked> */
.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 0;
  padding: 0;
  cursor: pointer;
  background: var(--night-40);
  transition: background var(--dur-base) var(--ease-out);
}
.switch::before {
  content: "";
  position: absolute;
  inset: -8px;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(7, 10, 38, 0.25);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch[aria-checked="true"] {
  background: var(--radiant-royal);
}
.switch[aria-checked="true"]::after {
  transform: translateX(18px);
}
.switch:hover {
  background: var(--night-60);
}
.switch[aria-checked="true"]:hover {
  background: var(--midnight-blue);
}
.switch[disabled] {
  background: var(--silver-phoenix);
  cursor: not-allowed;
  box-shadow: inset 0 0 0 1px var(--night-40);
}
.switch[disabled]::after {
  box-shadow: none;
  background: var(--night-40);
}
.switch[disabled][aria-checked="true"] {
  background: var(--radiant-royal-40);
}
.switch[disabled][aria-checked="true"]::after {
  background: var(--white);
}

/* Gesegmenteerde keuze / filters */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--silver-phoenix);
  flex-wrap: wrap;
}
.seg-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.seg-btn:hover {
  color: var(--fg-1);
  background: rgba(255, 255, 255, 0.6);
}
.seg-btn[aria-pressed="true"] {
  background: var(--white);
  color: var(--fg-1);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.seg-count {
  font-size: 12px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

/* Keuzekaart (radio-achtig) */
.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 0;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition:
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
  width: 100%;
}
.choice:hover {
  box-shadow: inset 0 0 0 1px var(--midnight-blue);
}
.choice[aria-pressed="true"] {
  background: var(--royal-8);
  box-shadow: inset 0 0 0 2px var(--radiant-royal);
}
.choice[disabled] {
  background: var(--silver-phoenix);
  box-shadow: none;
  cursor: not-allowed;
}
.radio-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--night-40);
  background: var(--white);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.choice[aria-pressed="true"] .radio-dot {
  box-shadow: inset 0 0 0 6px var(--radiant-royal);
}

/* Status-badges: icoon + tekst, kleur is ondersteunend */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
}
.badge .i {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}
.b-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.b-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.b-err {
  background: var(--err-bg);
  color: var(--err-fg);
}
.b-info {
  background: var(--info-bg);
  color: var(--info-fg);
}
.b-neutral {
  background: var(--silver-phoenix);
  color: var(--fg-2);
}
.b-outline {
  background: transparent;
  color: var(--fg-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.b-demo {
  background: var(--midnight-blue);
  color: var(--radiant-royal-60);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  height: 22px;
  padding: 0 9px;
}
.b-ext {
  background: transparent;
  color: var(--midnight-blue);
  box-shadow: inset 0 0 0 1px var(--radiant-royal);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  height: 22px;
  padding: 0 9px;
}

/* Origin-label (herkomst van een afzenderregel) */
.origin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-2);
}
.origin .i {
  width: 16px;
  height: 16px;
  color: var(--fg-3);
}

/* Meldingen */
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
}
.notice .i {
  margin-top: 1px;
}
.notice strong {
  font-weight: 600;
}
.n-info {
  background: var(--info-bg);
  color: var(--info-fg);
}
.n-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.n-warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.n-err {
  background: var(--err-bg);
  color: var(--err-fg);
}
.n-neutral {
  background: var(--silver-phoenix);
  color: var(--fg-2);
}
.n-demo {
  background: var(--white);
  color: var(--fg-2);
  box-shadow: inset 0 0 0 1px var(--radiant-royal-60);
}

/* Panelen en lijsten */
.panel {
  background: var(--bg-panel);
  border-radius: var(--radius-xl);
  padding: 28px;
}
.panel-tight {
  padding: 20px 24px;
}
.sub {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}
.rows > * + * {
  border-top: 1px solid var(--line);
}
.opt-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 0;
}
.opt-row.is-off .opt-title {
  color: var(--fg-2);
}

/* Tabellen (beheer) */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-3);
  padding: 10px 14px;
  white-space: nowrap;
}
.table td {
  padding: 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  color: var(--fg-1);
}
.table tr.is-hover td,
.table tbody tr:hover td {
  background: var(--white);
}
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

/* Navigatie */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--fg-2);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover {
  background: var(--silver-phoenix);
  color: var(--fg-1);
}
.nav-item[aria-current="page"] {
  background: var(--radiant-royal-40);
  color: var(--midnight-blue);
  font-weight: 600;
}
.nav-item .nav-meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-3);
}
.nav-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-3);
  padding: 0 14px;
  letter-spacing: 0.02em;
}
.kbd {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-2);
  font-family: var(--font-body);
}

/* Outlook-mappenvoorbeeld (schematisch, geen live weergave) */
.ofolder {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--fg-1);
}
.ofolder.is-inbox {
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600;
}
.ofolder.is-off {
  color: var(--fg-3);
}
.ofolder .ometa {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-3);
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--fg-2);
}

/* Dialogen */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 38, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  animation: umi-fade var(--dur-base) var(--ease-out);
}
.dialog {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--heart-of-ice);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: umi-rise var(--dur-base) var(--ease-out);
}
.dialog-lg {
  max-width: 760px;
}
.dialog-static {
  position: relative;
  animation: none;
}
@keyframes umi-fade {
  from {
    opacity: 0;
  }
}
@keyframes umi-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border-radius: var(--radius-pill);
  background: var(--night);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: umi-rise var(--dur-base) var(--ease-out);
  max-width: calc(100vw - 32px);
}
.toast .i {
  color: #9fe0bf;
}
.toast-static {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  display: inline-flex;
  animation: none;
}

/* Opslagbalk */
.savebar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 12px 12px 22px;
  border-radius: var(--radius-pill);
  background: var(--night);
  color: var(--white);
  box-shadow: var(--shadow-lg);
}
.savebar .btn-secondary {
  color: var(--white);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.savebar .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  box-shadow: inset 0 0 0 1px var(--white);
}

/* Skeleton */
.skel {
  background: linear-gradient(
    90deg,
    var(--silver-phoenix) 0%,
    #f3f5f9 50%,
    var(--silver-phoenix) 100%
  );
  background-size: 200% 100%;
  border-radius: 8px;
  animation: umi-shimmer 1.4s ease-in-out infinite;
}
@keyframes umi-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Schermlezers */
.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;
}

@media (prefers-reduced-motion: reduce) {
  .umi *,
  .umi *::before,
  .umi *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
