/* Onderzoekenplanner – mobiele app.
   Zelfde kleuren als de web-app (planner-web/style/main.css); licht en
   donker volgen het systeem. Ontworpen voor de telefoon: grote knoppen,
   menu onderaan, ruimte voor de inkeping en de balk van iOS. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --text: #1c2420;
  --muted: #5b665f;
  --border: #d6dcd7;
  --primary: #2f6b4f;
  --primary-hover: #255840;
  --primary-text: #ffffff;
  --focus: #1f6feb;
  --danger: #b42318;
  --info-bg: #e8f1fb;   --info-text: #164a7a;
  --success-bg: #e7f4ec; --success-text: #1d5e3a;
  --warning-bg: #fdf3e0; --warning-text: #7a4b07;
  --error-bg: #fdecea;  --error-text: #8f1d14;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --topbar-height: 52px;
  --tabbar-height: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211e;
    --surface-2: #232a26;
    --text: #e6ebe7;
    --muted: #a3ada6;
    --border: #343d38;
    --primary: #5fae86;
    --primary-hover: #74c19a;
    --primary-text: #0d1a13;
    --focus: #6ea8fe;
    --danger: #f97066;
    --info-bg: #13283d;    --info-text: #b6d4f5;
    --success-bg: #12291c; --success-text: #a6dbbb;
    --warning-bg: #33260b; --warning-text: #f3cf8e;
    --error-bg: #3a1512;   --error-text: #f6b5ae;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}

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

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: 0 0 1rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.break { overflow-wrap: anywhere; }

/* ---------- Knoppen ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem;
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text);
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:active:not(:disabled) { background: var(--primary-hover); }
.btn-danger-quiet { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn-large { min-height: 52px; font-size: 1.05rem; }
.btn-small { min-height: 36px; padding: .3rem .8rem; }

/* ---------- Formulieren ---------- */

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field label { font-weight: 600; }
.field input, .field textarea, .field select {
  font: inherit; font-size: 1.05rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .65rem .75rem; min-height: 48px; width: 100%;
}
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--focus); }
.field textarea { min-height: auto; resize: vertical; }

/* ---------- Meldingen ---------- */

.alert { border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; }
.alert-info    { background: var(--info-bg);    color: var(--info-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-error   { background: var(--error-bg);   color: var(--error-text); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .55rem 1rem; font-size: .95rem;
}
.banner-offline { background: var(--warning-bg); color: var(--warning-text); }
.banner-update {
  position: fixed; left: .75rem; right: .75rem; z-index: 30;
  bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + .75rem);
  background: var(--info-bg); color: var(--info-text);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Opstarten en inloggen ---------- */

.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; }

.auth-page {
  min-height: 100vh; display: grid; align-items: start; justify-items: center;
  padding: calc(env(safe-area-inset-top) + 1.5rem) 1rem 1.5rem;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo { display: block; border-radius: 14px; margin-bottom: .75rem; }
.auth-brand { color: var(--primary); font-weight: 700; margin-bottom: .25rem; }
.auth-help { color: var(--muted); font-size: .9rem; margin: 1.25rem 0 0; }
.ios-hint summary { font-weight: 600; cursor: pointer; }
.ios-hint[open] summary { margin-bottom: .5rem; }

/* ---------- Raamwerk: bovenbalk, inhoud, menu onderaan ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 1rem 0;
  display: flex; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.content {
  padding: 1rem 1rem calc(var(--tabbar-height) + env(safe-area-inset-bottom) + 1.5rem);
  max-width: 640px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; min-height: var(--tabbar-height);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--primary); }
.tab-icon { font-size: 1.3rem; line-height: 1; }
.tabbar a { position: relative; }
.tab-badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 1.3em; padding: 0 .35em; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .72rem; line-height: 1.3em; text-align: center;
}

/* ---------- Onderdelen ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem; margin-bottom: 1rem;
}
.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.steps { margin: 0 0 .5rem; padding-left: 1.25rem; }
.steps li { margin-bottom: .35rem; }
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: flex; flex-direction: column; padding: .55rem 0; border-top: 1px solid var(--border); }
.upcoming li:first-child { border-top: 0; padding-top: 0; }

.pre-wrap { white-space: pre-wrap; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li + li { margin-top: .2rem; }
.empty-state { border: 1px dashed var(--border); border-radius: 12px; padding: 1.5rem 1rem; color: var(--muted); text-align: center; }
.alert-title { margin: 0; font-weight: 600; }
.alert ul { margin: .4rem 0 0; padding-left: 1.1rem; }

/* ---------- Bezoeken ---------- */

.page-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.page-header h1 { margin: 0; }
.fetched { margin: 0 0 .75rem; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 1rem;
  background: var(--surface-2); border-radius: var(--radius);
}
.segmented button {
  min-height: 40px; border: 0; border-radius: calc(var(--radius) - 2px);
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.group { margin-bottom: 1.25rem; }
.group h2 { margin-bottom: .5rem; }
.day-label { font-size: 1rem; color: var(--muted); text-transform: none; }
.group-respond { background: var(--warning-bg); border-radius: 12px; padding: .9rem; }
.group-respond h2 { color: var(--warning-text); }

.visit-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: 12px; margin-bottom: .6rem; overflow: hidden;
}
.visit-card.status-concept { border-left-color: #d98e04; }
.visit-card.status-gepland { border-left-color: var(--primary); }
.visit-card.status-afgewezen, .visit-card.status-geannuleerd { border-left-color: var(--danger); opacity: .85; }
.visit-card.status-uitgevoerd { border-left-color: var(--muted); }
.visit-link { display: block; padding: .7rem .85rem; color: var(--text); text-decoration: none; }
.visit-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.visit-time { font-weight: 700; }
.visit-title { font-weight: 600; margin-top: .15rem; }
.visit-card .respond { padding: 0 .85rem .75rem; }

.badge { display: inline-block; flex-shrink: 0; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-concept { background: var(--warning-bg); color: var(--warning-text); }
.badge-gepland { background: var(--success-bg); color: var(--success-text); }
.badge-afgewezen, .badge-geannuleerd { background: var(--error-bg); color: var(--error-text); }

.respond-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.respond .alert { margin-bottom: .6rem; }
.respond .field { margin-bottom: .6rem; }
.btn-danger { background: var(--danger); color: #fff; }

.callout {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .85rem 1rem; margin-bottom: 1rem; border-radius: 12px;
  background: var(--warning-bg); color: var(--warning-text); text-decoration: none;
}
.back-link { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-weight: 600; }
.visit-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.visit-head h1 { margin-bottom: .75rem; }
.panel-respond { border-color: #d98e04; }

/* ---------- Beschikbaarheid ---------- */

.item-card {
  display: block; padding: .75rem .9rem; margin-bottom: .6rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: 12px; color: var(--text); text-decoration: none;
}
.item-card.status-concept, .item-card.status-heropend { border-left-color: #d98e04; }
.item-card.status-ingediend { border-left-color: var(--primary); }
.nav-card { border-left-color: var(--primary); }
.badge-ingediend { background: var(--success-bg); color: var(--success-text); }
.badge-heropend { background: var(--warning-bg); color: var(--warning-text); }
.badge-new { background: var(--info-bg); color: var(--info-text); margin-top: .3rem; }
.text-warning { color: var(--warning-text); margin-top: .25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1.5rem; }
.section-head h2 { margin: 0; }

.slot-grid { width: 100%; border-collapse: separate; border-spacing: 4px; margin: 0 -4px 1rem; }
.slot-grid th { font-size: .85rem; font-weight: 600; color: var(--muted); text-align: left; }
.slot-grid thead th { text-align: center; }
.slot {
  width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--error-text); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.slot.slot-off { background: var(--error-bg); border-color: var(--danger); }
.slot:disabled { cursor: default; }

/* ---------- Berichten ---------- */

.chat { display: flex; flex-direction: column; gap: .6rem; margin: .5rem 0 1rem; }
.bubble {
  max-width: 88%; padding: .55rem .75rem; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.bubble p { margin: .15rem 0 0; }
.bubble-planning { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble-own { align-self: flex-end; background: var(--success-bg); color: var(--success-text); border-color: transparent; border-bottom-right-radius: 4px; }
.bubble-system { align-self: stretch; max-width: none; border-style: dashed; background: transparent; font-size: .95rem; }
.bubble-meta { display: flex; justify-content: space-between; gap: .75rem; font-size: .78rem; color: var(--muted); }
.bubble-own .bubble-meta { color: inherit; opacity: .8; }
.call-actions { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.call-actions .call-reference { margin: 0 0 .15rem; color: var(--muted); }
.call-actions .call-status { margin: 0 0 .4rem; font-weight: 600; }
.bubble-link { display: inline-block; margin-top: .3rem; font-size: .9rem; font-weight: 600; }

.composer {
  position: sticky; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
  background: var(--bg); padding: .5rem 0; display: flex; flex-direction: column; gap: .5rem;
}
.composer textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .75rem; resize: vertical;
}
.composer .alert { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; align-self: flex-start;
  padding: .2rem .3rem .2rem .7rem; border-radius: 999px; background: var(--info-bg); color: var(--info-text); font-size: .85rem;
}
.chip-close { border: 0; background: transparent; color: inherit; font-size: 1.1rem; min-width: 32px; min-height: 32px; cursor: pointer; }
