/*
  App-schil: mobiel eerst, met zijbalk vanaf 768 px en detailpaneel vanaf 1024 px.
  De agenda is het startscherm; de schil houdt navigatie en inhoud uit elkaar.
*/

body {
  overflow-x: hidden;
}

/* Mobiel: demo-balk, bovenbalk, inhoud, onderbalk. Geen zijbalk. */
.shell {
  display: grid;
  grid-template-areas:
    "demo"
    "topbar"
    "content"
    "bottomnav";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 100dvh;
}

/* ---------------------------------------------------------- Zijbalk */

.sidebar {
  display: none;
  grid-area: sidebar;
  flex-direction: column;
  gap: var(--space-5);
  min-height: 0;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: var(--line-thin) solid var(--line);
  background: var(--surface);
}

.sidebar__brand {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--brand);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.sidebar__brand small,
.sidebar__brand-sub {
  display: block;
  margin-top: var(--space-1);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.nav__section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-decoration: none;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) linear;
}

.nav__item .ph {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 20px;
}

.nav__item:hover {
  background: var(--surface-2);
}

.nav__item--active,
.nav__item[aria-current="page"] {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: var(--weight-semibold);
}

.nav__item--active .ph,
.nav__item[aria-current="page"] .ph {
  color: currentColor;
}

.nav__item--active:hover,
.nav__item[aria-current="page"]:hover {
  background: var(--brand);
}

.nav__badge {
  margin-left: auto;
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: var(--line-thin) solid var(--line);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
}

.sidebar__user:hover {
  background: var(--surface-2);
}

.sidebar__user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
}

.sidebar__user-role {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.3;
}

/* --------------------------------------------------------- Bovenbalk */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  grid-area: topbar;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 60px;
  padding: var(--space-2) var(--space-4);
  border-bottom: var(--line-thin) solid var(--line);
  background: var(--surface);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.topbar__title {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__date {
  display: block;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.3;
}

.topbar__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-1);
}

/* ---------------------------------------------------------- Inhoud */

.content {
  grid-area: content;
  min-width: 0;
  min-height: 0;
  padding: var(--space-4) var(--space-4) var(--space-7);
}

.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.page__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}

.page__subtitle {
  margin: var(--space-1) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.page__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* ----------------------------------------------------- Zwevende plus */

.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(
    var(--bottomnav-height) + env(safe-area-inset-bottom) + var(--space-4)
  );
  z-index: calc(var(--z-sticky) + 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fab-size);
  height: var(--fab-size);
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) linear;
}

.fab .ph {
  font-size: 24px;
}

.fab:hover {
  transform: translateY(-2px) scale(1.03);
}

.fab:active {
  transform: scale(0.96);
}

/* -------------------------------------------------------- Onderbalk */

.bottomnav {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: grid;
  grid-area: bottomnav;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding: var(--space-1) var(--space-1)
    calc(var(--space-1) + env(safe-area-inset-bottom));
  border-top: var(--line-thin) solid var(--line);
  background: var(--surface);
}

.bottomnav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: var(--tap-min);
  min-height: 56px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) linear;
}

.bottomnav__item .ph {
  font-size: 22px;
}

.bottomnav__item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.bottomnav__item--active,
.bottomnav__item[aria-current="page"] {
  background: var(--surface-2);
  color: var(--brand);
  font-weight: var(--weight-semibold);
}

/* ---------------------------------------------------- Detailpaneel */

.detail-panel {
  display: none;
}

.detail-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: var(--line-thin) solid var(--line);
}

.detail-panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.detail-panel__body {
  flex: 1;
  min-height: 0;
  padding: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-panel__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: var(--line-thin) solid var(--line);
  background: var(--surface);
}

/* --------------------------------------------------------- Demo-balk */

.demo-bar {
  display: flex;
  grid-area: demo;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}

.demo-bar a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.demo-bar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.demo-bar .btn {
  min-height: var(--tap-sm);
  border-color: currentColor;
  background: transparent;
  color: inherit;
  font-size: var(--text-xs);
}

.demo-bar .btn:hover:not(:disabled):not([aria-disabled="true"]) {
  background: transparent;
  box-shadow: none;
  transform: translateY(-1px);
}

/* ------------------------------------------------------------ Login */

.login {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--bg);
}

.login__brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-5);
  background: var(--brand);
  color: var(--brand-ink);
}

.login__brand-top,
.login__brand-bottom {
  min-width: 0;
}

.login__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: 1.1;
  text-decoration: none;
}

.login__brand-title {
  max-width: 14ch;
  margin: var(--space-5) 0 0;
  color: inherit;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.login__tagline {
  max-width: 32ch;
  margin: var(--space-3) 0 0;
  color: inherit;
  font-size: var(--text-md);
  line-height: var(--leading-normal);
}

.login__brand-meta {
  margin: 0;
  color: inherit;
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.login__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.login__form-title {
  margin: 0 0 var(--space-1);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.login__form-intro {
  margin: 0 0 var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.login__form .stack {
  gap: var(--space-4);
}

.login__form .btn--primary {
  width: 100%;
}

.login__demo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.login__demo-title {
  grid-column: 1 / -1;
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login__demo .btn {
  justify-content: flex-start;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login__demo .btn .ph {
  color: var(--muted);
}

/* -------------------------------------------------- Offline-banner */

.offline-banner {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--warn);
  color: var(--on-warn);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
}

.offline-banner.is-visible,
.offline-banner[data-visible="true"] {
  display: flex;
}

.offline-banner .ph {
  flex: 0 0 auto;
  font-size: 16px;
}

/* ------------------------------------------------------- Printen */

.print-only {
  display: none !important;
}

@media print {
  .print-only {
    display: block !important;
  }

  .sidebar,
  .topbar,
  .bottomnav,
  .fab,
  .demo-bar,
  .offline-banner,
  .toast,
  .overlay,
  .sheet,
  .sheet__backdrop,
  .sheet-backdrop,
  .modal,
  .detail-panel {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 12pt;
  }

  .shell {
    display: block;
    min-height: 0;
  }

  .content {
    padding: 0;
  }

  .page {
    max-width: none;
  }

  .card,
  .panel,
  .table {
    border-color: #000000;
    box-shadow: none;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }
}

/* ---------------------------------------------------- Breakpoints */

@media (min-width: 768px) {
  .shell {
    grid-template-areas:
      "demo demo"
      "sidebar content";
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    align-self: stretch;
    max-height: 100dvh;
    position: sticky;
    top: 0;
  }

  .topbar,
  .bottomnav,
  .fab {
    display: none;
  }

  .content {
    padding: var(--space-6);
  }

  .page__title {
    font-size: var(--text-3xl);
  }

  .login {
    grid-template-columns: minmax(300px, 44%) minmax(0, 1fr);
  }

  .login__brand {
    padding: var(--space-7);
  }

  .login__form {
    max-width: 480px;
    padding: var(--space-7);
  }
}

@media (min-width: 1024px) {
  .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-panel);
    display: flex;
    flex-direction: column;
    width: var(--detail-width);
    max-width: 100vw;
    overflow: hidden;
    border-left: var(--line-thin) solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(100%);
    transition:
      transform var(--dur-panel) var(--ease-out),
      opacity var(--dur-panel) var(--ease-out),
      visibility 0s linear var(--dur-panel);
  }

  .detail-panel.is-open,
  .detail-panel[data-open="true"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition:
      transform var(--dur-panel) var(--ease-out),
      opacity var(--dur-panel) var(--ease-out);
  }

  .shell--detail .content {
    padding-right: calc(var(--detail-width) + var(--space-6));
  }

  .login {
    grid-template-columns: minmax(380px, 42%) minmax(0, 1fr);
  }
}
