/* WSV Meldingen — mobile-first.
 * Light: WSV brand (deep blue + warm yellow) matching cwo-toets.
 * Dark : warm-paper inverse, same as CNC dashboard. Toggle via [data-theme].
 */

:root {
  --brand: #2f5597;
  --brand-soft: #4a7bc4;
  --brand-deep: #1f3d75;
  --accent: #fbae02;
  --accent-soft: #ffd067;

  --bg: #f4f8fc;
  --bg-card: #ffffff;
  --bg-soft: #eaf1f9;
  --bg-pill: #eaf1f9;
  --text: #1a2540;
  --text-muted: #5a6b85;
  --text-faint: #8693a8;
  --border: #dde5ef;
  --border-strong: #b8c7dc;

  --ok: #4a8a5e;     --ok-bg: #e6f1ea;
  --warn: #c89200;   --warn-bg: #fbf1d8;
  --err: #b85858;    --err-bg: #f6e6e6;
  --info: #5b81a8;   --info-bg: #e6eef6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(31, 61, 117, 0.08);
  --shadow-md: 0 4px 14px rgba(31, 61, 117, 0.10);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --brand: #8aa8d8;
  --brand-soft: #6f8ec0;
  --brand-deep: #b6c8e6;
  --accent: #d8a64a;
  --accent-soft: #b88a36;

  --bg: #1a1612;
  --bg-card: #221d18;
  --bg-soft: #2a241e;
  --bg-pill: #2a241e;
  --text: #e8dfd0;
  --text-muted: #a39888;
  --text-faint: #6f6759;
  --border: #2e2820;
  --border-strong: #3a3328;

  --ok: #7eb888;     --ok-bg: rgba(126, 184, 136, 0.14);
  --warn: #d4a86a;   --warn-bg: rgba(212, 168, 106, 0.16);
  --err: #d68080;    --err-bg: rgba(214, 128, 128, 0.16);
  --info: #8fa8c8;   --info-bg: rgba(143, 168, 200, 0.16);

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --- */

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.site-header .brand:hover { text-decoration: none; }
.site-header img.logo {
  width: 34px; height: 34px;
  border-radius: 6px;
  object-fit: contain;
  background: white;
}
.site-header .titlewrap { display: flex; flex-direction: column; line-height: 1.15; }
.site-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--brand-deep);
}
.site-header .sub { font-size: 12px; color: var(--text-muted); }
.site-header .topnav {
  display: flex; gap: 4px;
  font-size: 14px;
  flex: 1;
  justify-content: center;
}
.site-header .topnav a {
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.site-header .topnav a.active {
  color: var(--brand);
  background: var(--bg-soft);
}
.site-header .topright {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--bg-soft); }

/* On narrow screens the topnav wraps under the brand. */
@media (max-width: 600px) {
  .site-header { flex-wrap: wrap; padding: 8px 12px; }
  .site-header .topnav {
    order: 3; width: 100%; justify-content: flex-start;
    border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px;
  }
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}

/* --- Cards --- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.center { text-align: center; }
.card.empty { text-align: center; padding: 32px 18px; }
.card h2 { margin: 0 0 10px; font-size: 20px; color: var(--brand-deep); }
.card .lead { color: var(--text); }
.card .sub-head { margin: 18px 0 8px; font-size: 15px; color: var(--brand-deep); }
.card p.multiline { white-space: pre-wrap; word-wrap: break-word; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 4px 4px 14px;
}
.page-head h2 { margin: 0; font-size: 22px; color: var(--brand-deep); }

/* --- Banners --- */

.banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 8px 0 14px;
  font-size: 14px;
}
.banner.ok   { background: var(--ok-bg);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.banner.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner.err  { background: var(--err-bg);  border-color: color-mix(in srgb, var(--err) 30%, transparent); }

/* --- Forms --- */

.form-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-muted); }
.form-stack input[type="text"],
.form-stack input[type="email"],
.form-stack select,
.form-stack textarea,
.inline-form input[type="text"],
.inline-form select {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.form-stack textarea { min-height: 110px; resize: vertical; }
.form-stack input[type="file"] {
  padding: 8px; background: var(--bg-soft);
  border-radius: var(--radius-sm); border: 1px dashed var(--border-strong);
  width: 100%;
}
.checkbox { display: flex; align-items: center; gap: 8px; flex-direction: row !important; }
.checkbox.inline { display: inline-flex; margin-right: 10px; }
.muted { color: var(--text-muted); }
.muted.small, .small { font-size: 12px; }

/* --- Buttons --- */

.btn, .btn-link {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-weight: 500;
  text-align: center;
  border: 1px solid transparent;
  background: var(--brand);
  color: white;
  text-decoration: none;
  display: inline-block;
  font-size: 15px;
}
.btn:hover { background: var(--brand-deep); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--brand);
}
.btn.secondary:hover { background: var(--bg-soft); }
.btn-link {
  background: none;
  color: var(--brand);
  padding: 6px 8px;
  border-color: transparent;
}
.btn-link:hover { background: var(--bg-soft); text-decoration: none; }
.btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* --- List --- */

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.seg {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  font-size: 13px;
}
.seg a {
  padding: 7px 14px;
  color: var(--text-muted);
}
.seg a.active {
  background: var(--brand);
  color: white;
}
.seg a:hover { text-decoration: none; }

.melding-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.melding-row {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 100ms, box-shadow 100ms;
}
.melding-row:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.melding-row .row-top { display: flex; align-items: baseline; gap: 8px; }
.melding-row .id { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 13px; }
.melding-row .title { font-weight: 600; color: var(--text); flex: 1; }
.melding-row .row-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.melding-row .row-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 13px; color: var(--text-muted); }

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tag.soort { background: var(--info-bg); color: var(--info); border-color: transparent; }
.tag.categorie { background: var(--bg-soft); }
.tag.groep { background: var(--accent-soft); color: var(--brand-deep); border-color: transparent; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
  font-weight: 500;
}
.status-aangemeld         { background: var(--info-bg);  color: var(--info); }
.status-in-behandeling    { background: var(--warn-bg);  color: var(--warn); }
.status-wacht-op-externe-leverancier,
.status-wacht-op-bestelling { background: var(--bg-pill); color: var(--text-muted); }
.status-gereed            { background: var(--ok-bg);    color: var(--ok); }

.prio {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.prio-hoog    { background: var(--err-bg);  color: var(--err); }
.prio-normaal { background: var(--info-bg); color: var(--info); }
.prio-laag    { background: var(--bg-pill); color: var(--text-muted); }

/* --- Detail --- */

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 8px;
}
.meta-grid > div { display: flex; flex-direction: column; }
.meta-grid label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint);
}
@media (min-width: 540px) {
  .meta-grid { grid-template-columns: repeat(4, 1fr); }
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 540px) {
  .action-grid { grid-template-columns: 1fr 1fr; }
}
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { display: flex; flex-direction: column; font-size: 13px; color: var(--text-muted); flex: 1 1 140px; }
.inline-form select, .inline-form input[type="text"] { font-size: 15px; padding: 9px 10px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.photo-grid img {
  width: 100%; height: 120px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

.comment-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; }
.comment {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.comment.question { background: var(--warn-bg); border-left: 3px solid var(--warn); }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.comment-head .right { margin-left: auto; }

.event-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.event-list li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.event-list code { background: var(--bg-soft); padding: 1px 4px; border-radius: 3px; }

details.card summary { cursor: pointer; font-weight: 600; color: var(--brand-deep); }

/* --- Admin --- */

.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}
.user-table th { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.group-form { display: flex; flex-wrap: wrap; gap: 6px; }
.group-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
.group-list li { display: flex; gap: 10px; align-items: center; }

.ok-tag  { display: inline-block; background: var(--ok-bg); color: var(--ok); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.err-tag { display: inline-block; background: var(--err-bg); color: var(--err); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

@media (max-width: 640px) {
  .user-table thead { display: none; }
  .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; width: 100%; }
  .user-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; padding: 8px; }
  .user-table td { border-bottom: none; padding: 4px 0; }
}
