/* ============================================================
   styles.css — Kalender PWA
   ============================================================ */

/* --- Kleuren & maten -------------------------------------- */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --ink: #1c2220;
  --ink-2: #5b6461;
  --ink-3: #8b928f;
  --line: #e2ded5;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe5;
  --danger: #b4412f;
  --today: #c8553d;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 8px 24px rgba(20, 30, 25, .08);
  --radius: 12px;
  --top-h: 56px;
  --side-w: 272px;
  --hour-h: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c2220;
    --surface-2: #232a27;
    --ink: #eef1ef;
    --ink-2: #a9b2ae;
    --ink-3: #78817d;
    --line: #2e3633;
    --accent: #5fb39a;
    --accent-ink: #0f1513;
    --accent-soft: #23392f;
    --danger: #e0775f;
    --today: #ef8a6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* --- Basis ------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* --- Knoppen & velden ------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 38px; padding: 0; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

label.field { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time],
input[type=number], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 15px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.dt { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 6px; }
.dt input { min-width: 0; }
.dt:has(input.hidden) { grid-template-columns: minmax(0, 1fr); }
.modal-body { min-width: 0; }
.modal-body * { min-width: 0; }
.stack { display: grid; gap: 12px; }

/* --- Losse pagina's (login, uitnodiging) ------------------ */
.center-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.auth-card { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }

/* ============================================================
   App-indeling
   ============================================================ */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100%; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: auto;
  padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--top-h); flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar .title { font-size: 18px; font-weight: 650; margin: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.topbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; min-height: 36px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.view { flex: 1; min-height: 0; overflow: auto; position: relative; }
.menu-btn { display: none; }
.scrim { display: none; }

/* --- Zijbalk ---------------------------------------------- */
.side .brand { padding: 4px 8px; margin-bottom: 8px; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 14px 8px 6px; }
.cal-group { margin-bottom: 4px; }
.cal-name { font-weight: 600; padding: 6px 8px 2px; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.sub-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.sub-item:hover { background: var(--surface-2); }
.sub-item .box { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--c); flex: none; display: grid; place-items: center; }
.sub-item.on .box { background: var(--c); }
.sub-item.on .box::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.sub-item .badge { margin-left: auto; font-size: 11px; color: var(--ink-3); }
.side-nav { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
.side-nav a:hover, .side-nav a.on { background: var(--surface-2); }

/* --- Zwevende knop ---------------------------------------- */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 16px; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
  font-size: 28px; cursor: pointer; display: grid; place-items: center; z-index: 20;
}

/* ============================================================
   Maandweergave
   ============================================================ */
.month { display: grid; grid-template-rows: auto 1fr; height: 100%; min-height: 520px; }
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-head div { padding: 8px; font-size: 12px; text-transform: uppercase; color: var(--ink-3); letter-spacing: .05em; text-align: center; }
.month-grid { grid-auto-rows: minmax(92px, 1fr); border-top: 1px solid var(--line); }
.mday { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.mday:nth-child(7n) { border-right: 0; }
.mday.other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.mday.other .dnum { color: var(--ink-3); }
.mday:hover { background: var(--surface-2); }
.dnum { font-size: 13px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; align-self: center; }
.mday.today .dnum { background: var(--today); color: #fff; }
.chip {
  font-size: 12px; line-height: 1.25; padding: 2px 6px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.chip.allday { background: var(--c); color: #fff; }
.chip.timed { display: flex; align-items: center; gap: 4px; }
.chip.timed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.chip.timed:hover { background: var(--surface-2); }
.chip .t { color: var(--ink-2); }
.more { font-size: 12px; color: var(--ink-2); padding: 0 6px; white-space: nowrap; }

/* ============================================================
   Week- en dagweergave
   ============================================================ */
.tg { display: grid; grid-template-columns: 52px 1fr; min-width: 0; }
.tg-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 52px 1fr; }
.tg-days { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.tg-day-h { text-align: center; padding: 6px 2px; border-left: 1px solid var(--line); cursor: pointer; }
.tg-day-h .wd { font-size: 11px; text-transform: uppercase; color: var(--ink-3); letter-spacing: .05em; }
.tg-day-h .dn { font-size: 20px; font-weight: 600; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; margin: 0 auto; }
.tg-day-h.today .dn { background: var(--today); color: #fff; }
.tg-allday { grid-column: 1 / -1; display: grid; grid-template-columns: 52px 1fr; border-top: 1px solid var(--line); }
.tg-allday .lbl { font-size: 11px; color: var(--ink-3); padding: 4px; text-align: right; }
.tg-allday .cells { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.tg-allday .cell { border-left: 1px solid var(--line); padding: 2px; display: grid; gap: 2px; min-height: 24px; align-content: start; }
.tg-hours { position: relative; }
.tg-hour { height: var(--hour-h); font-size: 11px; color: var(--ink-3); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.tg-cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); position: relative;
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hour-h); }
.tg-col { position: relative; border-left: 1px solid var(--line); height: calc(var(--hour-h) * 24); }
.tg-col.today { background: color-mix(in srgb, var(--today) 4%, transparent); }
.tg-ev {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 3px 6px;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); border-left: 3px solid var(--c);
  font-size: 12px; line-height: 1.2; overflow: hidden; cursor: pointer;
}
.tg-ev:hover { filter: brightness(.97); }
.tg-ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev span { color: var(--ink-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev.avail { background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--c) 12%, var(--surface)) 0 6px, var(--surface) 6px 12px); border-left-style: dashed; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--today); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--today); }

/* ============================================================
   Agendaweergave (lijst)
   ============================================================ */
.agenda { max-width: 760px; margin: 0 auto; padding: 8px 16px 96px; }
.ag-day { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ag-date { text-align: center; }
.ag-date .wd { font-size: 12px; text-transform: uppercase; color: var(--ink-3); }
.ag-date .dn { font-size: 24px; font-weight: 650; line-height: 1.1; }
.ag-date.today .dn { color: var(--today); }
.ag-list { display: grid; gap: 6px; }
.ag-item { display: grid; grid-template-columns: 4px 1fr; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.ag-item:hover { background: var(--surface-2); }
.ag-item .bar { background: var(--c); border-radius: 2px; }
.ag-item .when { font-size: 13px; color: var(--ink-2); }
.ag-item .what { font-weight: 600; }
.ag-item .where { font-size: 13px; color: var(--ink-2); }
.empty { text-align: center; color: var(--ink-2); padding: 48px 16px; }

/* ============================================================
   Dialoog / bottom sheet
   ============================================================ */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(10, 15, 13, .4); padding: 16px; }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100% - 32px); overflow: auto;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.weekdays label { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; font-size: 13px; }
.weekdays input { display: none; }
.weekdays label:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.detail-row { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.detail-row .ic { color: var(--ink-3); text-align: center; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c); vertical-align: -1px; }
.pre { white-space: pre-wrap; }

/* --- Melding onderaan ------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 100;
  box-shadow: var(--shadow); font-size: 14px; max-width: calc(100% - 32px);
}

/* ============================================================
   Beheer & instellingen
   ============================================================ */
.page { max-width: 900px; margin: 0 auto; padding: 16px 16px 96px; display: grid; gap: 16px; align-content: start; }
.section-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 160px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: color-mix(in srgb, var(--today) 15%, transparent); color: var(--today); }
.access-grid { display: grid; grid-template-columns: 1fr 170px; gap: 6px 10px; align-items: center; margin-top: 8px; width: 100%; }
.access-grid select { min-height: 34px; padding: 4px 8px; font-size: 14px; }
.linkbox { display: flex; gap: 6px; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.cal-card-link { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: var(--ink); }
.cal-card-link:hover { background: var(--surface-2); }

/* ============================================================
   Mobiel
   ============================================================ */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .app.side-open .side { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 15, 13, .35); z-index: 30; }
  .menu-btn { display: inline-flex; }
  .topbar { height: calc(var(--top-h) + env(safe-area-inset-top)); padding-left: 6px; padding-right: 6px; }
  .topbar .title { font-size: 16px; margin: 0 4px; flex: 1; min-width: 0; }
  .topbar .spacer { display: none; }
  .topbar .btn { padding: 0 10px; }
  .topbar .btn.icon { width: 32px; padding: 0; }
  .hide-mobile { display: none !important; }
  .month-grid { grid-auto-rows: minmax(64px, 1fr); }
  .chip.timed .t { display: none; }
  .chip { font-size: 11px; padding: 1px 4px; }
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92%; padding-bottom: env(safe-area-inset-bottom); }
  .grid2 { grid-template-columns: 1fr; }
  .access-grid { grid-template-columns: 1fr 140px; }
}
@media (min-width: 861px) { .show-mobile { display: none !important; } }
