/* ============================================================
   NewsFeed — licht, verzorgd thema (bewuste afwijking van het
   donkere neon-thema dat de rest van de workspace gebruikt), met een
   optionele donkere variant. Categoriekleuren staan NIET meer als losse
   --cat-*-tokens hier — sinds bronnen/categorieën in SQLite leven
   (src/sourceRegistry.js) komen kleuren rechtstreeks uit de API-data en
   worden ze als inline style toegepast (zie app.js/admin.js); een vaste
   tokenlijst hier zou na een categoriewijziging in het beheerscherm stil
   achterhaald raken.
   ============================================================ */
:root {
  --bg: #f7f8fb;
  --bg-soft: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f3f5fa;

  --ink: #111827;
  --ink-soft: #5b6472;
  --ink-muted: #9aa3b2;

  --line: #e6e8ee;
  --line-soft: #eef0f5;

  --brand: #2f6df6;
  --brand-dim: #1d4ed8;
  --brand-bg: rgba(47, 109, 246, 0.09);

  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.08);

  --overlay: rgba(17, 24, 39, 0.32);
  --toast-bg: var(--ink);
  --toast-ink: #ffffff;
  --ok: #16a34a;
  --topbar-bg: rgba(255, 255, 255, 0.85);

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 20px 48px rgba(17, 24, 39, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
}

/* Donkere variant: expliciete keuze (data-theme="dark") of stelselvoorkeur
   wanneer de gebruiker geen expliciete keuze maakte (data-theme="auto" of
   afwezig — zie theme.js). Vroeger onderdrukte een lege
   @media(prefers-color-scheme:dark)-blok hier de donkere modus actief door
   de lichte waarden te herhalen; dat is nu echt weggehaald. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #12151c;
    --bg-soft: #171b24;
    --surface: #1a1e28;
    --surface-2: #232936;

    --ink: #e7e9ee;
    --ink-soft: #a1a8b5;
    --ink-muted: #6b7280;

    --line: #2b303d;
    --line-soft: #262b37;

    --brand: #5b8dfb;
    --brand-dim: #7ba1ff;
    --brand-bg: rgba(91, 141, 251, 0.16);

    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.14);
    --warn: #f59e0b;
    --warn-bg: rgba(245, 158, 11, 0.14);

    --overlay: rgba(0, 0, 0, 0.55);
    --toast-bg: #2b303d;
    --toast-ink: #e7e9ee;
    --ok: #22c55e;
    --topbar-bg: rgba(18, 21, 28, 0.85);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
  }
}

html[data-theme="dark"] {
  --bg: #12151c;
  --bg-soft: #171b24;
  --surface: #1a1e28;
  --surface-2: #232936;

  --ink: #e7e9ee;
  --ink-soft: #a1a8b5;
  --ink-muted: #6b7280;

  --line: #2b303d;
  --line-soft: #262b37;

  --brand: #5b8dfb;
  --brand-dim: #7ba1ff;
  --brand-bg: rgba(91, 141, 251, 0.16);

  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.14);

  --overlay: rgba(0, 0, 0, 0.55);
  --toast-bg: #2b303d;
  --toast-ink: #e7e9ee;
  --ok: #22c55e;
  --topbar-bg: rgba(18, 21, 28, 0.85);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }
a { color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #4f8bff 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(47, 109, 246, 0.35);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(47, 109, 246, 0.45); }
.btn-outline {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-outline:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-bg); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { padding: 8px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
/* Zacht driftende gradient-mesh — brand-blauw + de Roadmap/Entra-categorie-
   tinten, zodat het ook een beetje verwijst naar de app zelf. Puur decoratief,
   geen interactie; @media (prefers-reduced-motion) hierboven bevriest 'm al. */
.login-screen::before {
  content: "";
  position: absolute;
  inset: -15%;
  background:
    radial-gradient(circle at 18% 22%, rgba(47, 109, 246, 0.38), transparent 42%),
    radial-gradient(circle at 82% 12%, rgba(124, 58, 237, 0.28), transparent 44%),
    radial-gradient(circle at 55% 92%, rgba(13, 148, 136, 0.26), transparent 46%);
  filter: blur(70px);
  animation: loginDrift 22s ease-in-out infinite alternate;
  z-index: 0;
}
.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.4;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
  mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 72%);
  z-index: 0;
}
@keyframes loginDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-4%, 3%, 0) scale(1.1); }
}
/* Op een donkere achtergrond doven dezelfde gradient-opacities zichtbaar uit
   — iets feller zetten zodat de mesh net zo goed leest als in het lichte thema. */
html[data-theme="dark"] .login-screen::before {
  background:
    radial-gradient(circle at 18% 22%, rgba(91, 141, 251, 0.45), transparent 42%),
    radial-gradient(circle at 82% 12%, rgba(167, 139, 250, 0.35), transparent 44%),
    radial-gradient(circle at 55% 92%, rgba(45, 212, 191, 0.3), transparent 46%);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .login-screen::before {
    background:
      radial-gradient(circle at 18% 22%, rgba(91, 141, 251, 0.45), transparent 42%),
      radial-gradient(circle at 82% 12%, rgba(167, 139, 250, 0.35), transparent 44%),
      radial-gradient(circle at 55% 92%, rgba(45, 212, 191, 0.3), transparent 46%);
  }
}
.login-card {
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: min(380px, 90vw);
  text-align: center;
  animation: loginCardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo { font-size: 40px; margin-bottom: 4px; filter: drop-shadow(0 4px 14px rgba(47, 109, 246, 0.35)); }
.login-card h1 { margin: 4px 0 2px; font-size: 22px; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 22px; }
.login-card input {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 14px; margin-bottom: 14px;
  background: var(--surface-2);
}
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
.login-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-mark { font-size: 20px; }
.topbar-search {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
.topbar-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }
.icon-search { width: 16px; height: 16px; color: var(--ink-muted); flex-shrink: 0; }
.topbar-search input { border: none; background: transparent; outline: none; font-size: 14px; flex: 1; color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.refresh-icon { display: inline-block; }
.refresh-icon.spinning { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; align-items: flex-start; }
.sidebar {
  width: 220px; flex-shrink: 0;
  padding: 18px 12px;
  position: sticky; top: 61px;
  height: calc(100vh - 61px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.sidebar-section { margin-bottom: 18px; }
.sidebar-section-bottom { border-top: 1px solid var(--line); padding-top: 14px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; border: none; background: transparent;
  cursor: pointer; font-size: 14px; color: var(--ink-soft); text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--brand-bg); color: var(--brand-dim); font-weight: 600; }
.nav-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, #999); flex-shrink: 0; box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent); }
.nav-label { flex: 1; }
.nav-count {
  font-size: 11.5px; font-weight: 700; color: var(--ink-muted);
  background: var(--surface-2); border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item.is-active .nav-count { background: rgba(47,109,246,.15); color: var(--brand-dim); }

.chip-row { display: none; gap: 8px; overflow-x: auto; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chip {
  flex-shrink: 0; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.chip.is-active { background: var(--dot, var(--brand)); color: #fff; border-color: transparent; }

.main { flex: 1; min-width: 0; padding: 22px 28px 60px; }
.view-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.view-toolbar h2 { margin: 0; font-size: 20px; }
.view-toolbar-actions { display: flex; align-items: center; gap: 14px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); cursor: pointer; user-select: none; }

.new-items-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(47,109,246,.35);
  animation: slideDown 0.35s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 26px; }
.day-group { display: flex; flex-direction: column; gap: 10px; }
.day-heading {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted); padding-left: 2px;
}
.card {
  --accent: var(--brand);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  display: flex; flex-direction: column; gap: 6px;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card.is-read { opacity: 0.62; }
.card.is-expanded { cursor: default; }
.card.is-expanded:hover { transform: none; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-chip {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--accent);
}
.source-chip { font-size: 12px; color: var(--ink-muted); }
.sev-chip {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
}
.sev-urgent { background: var(--danger-bg); color: var(--danger); }
.sev-high { background: var(--warn-bg); color: var(--warn); }
.card-title { font-size: 15px; font-weight: 650; margin: 0; line-height: 1.35; }
.card-summary {
  font-size: 13.2px; color: var(--ink-soft); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-bottom { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.card-time { font-size: 12px; color: var(--ink-muted); }
.card-actions { margin-left: auto; display: flex; gap: 4px; }
.card-actions button {
  background: none; border: none; cursor: pointer; color: var(--ink-muted); font-size: 15px; padding: 4px 6px; border-radius: 6px;
}
.card-actions button:hover { background: var(--surface-2); color: var(--ink); }
.card-actions button.is-on { color: var(--brand); }

.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.skeleton .bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; margin-bottom: 8px; }
.skeleton .bar.w60 { width: 60%; } .skeleton .bar.w90 { width: 90%; } .skeleton .bar.w40 { width: 40%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.empty-state, .load-more-wrap { text-align: center; color: var(--ink-muted); padding: 40px 0; }

/* ---------- Overlay (alleen nog de digest-modal gebruikt dit) ---------- */
.overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 40;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Inline artikel-uitklap (in de kaart zelf, i.p.v. een zijpaneel) ---------- */
.card-detail {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
  cursor: default;
  animation: expandDown 0.18s ease;
}
@keyframes expandDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.detail-meta { font-size: 12.5px; color: var(--ink-muted); }
.severity-banner { padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.severity-banner.urgent { background: var(--danger-bg); color: var(--danger); }
.severity-banner.high { background: var(--warn-bg); color: var(--warn); }
.detail-summary { font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; margin: 0; }
.ai-summary { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; font-size: 13.8px; line-height: 1.6; white-space: pre-wrap; }
.card-detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Digest modal ---------- */
.digest-modal {
  position: fixed; top: 8vh; left: 50%; transform: translateX(-50%);
  width: min(640px, 92vw); max-height: 82vh; z-index: 60;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  animation: popIn 0.22s cubic-bezier(.16,1,.3,1);
}
@keyframes popIn { from { opacity: 0; transform: translateX(-50%) scale(.97); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
.digest-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.digest-header h2 { margin: 0; font-size: 17px; flex-shrink: 0; }
.digest-range { display: flex; gap: 8px; margin-left: auto; }
.digest-body { padding: 20px 24px; overflow-y: auto; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; }
.digest-placeholder { color: var(--ink-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-ink); padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; z-index: 80; box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}

/* ---------- "Voor jou" (watchlist) ---------- */
.watch-chip {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn);
}
.cluster-chip {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.cluster-members { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.cluster-members strong { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.cluster-members a { color: var(--ink-soft); text-decoration: none; }
.cluster-members a:hover { color: var(--brand); text-decoration: underline; }
.relevance-reasons { font-size: 12.5px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px; }
.relevance-reasons span { background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }
.refresh-status-pill { font-size: 12px; color: var(--ink-muted); margin-left: 6px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .layout { flex-direction: column; align-items: stretch; width: 100%; }
  .chip-row { display: flex; width: 100%; }
  .main { padding: 16px 16px 60px; width: 100%; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand-name { display: none; }
  .refresh-label { display: none; }
}
