/* ==========================================================
   MijnGPH - dashboard.css
   App-layout, KPI's, ritformulier, tabel, dialogen
   ========================================================== */

body.app-body { background: var(--bg); }

.app {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1rem;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar .brand { padding: 0.25rem 0.5rem; }
.status-pill {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-blue);
  border-radius: var(--r-md);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.status-pill span:first-child { display: inline-flex; align-items: center; gap: 0.375rem; }
.status-pill .dot { color: var(--emerald); }
.status-pill strong { color: var(--teal-dark); }

.side-nav { list-style: none; display: grid; gap: 0.25rem; }
.side-nav a {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--r-md);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
}
.side-nav a:hover { background: var(--bg); color: var(--primary-deep); }
.side-nav a[aria-current="true"] { background: var(--primary); color: #fff; box-shadow: var(--sh-inset), 0 6px 16px -8px rgba(79, 70, 229, 0.6); }
.side-nav a [data-lucide], .side-nav a .lucide { width: 1.25rem; height: 1.25rem; }
.side-nav .count { margin-left: auto; font-size: 0.75rem; font-weight: 600; padding: 0.0625rem 0.5rem; border-radius: var(--r-full); background: var(--bg-blue); color: var(--primary-deep); }
.side-nav a[aria-current="true"] .count { background: rgba(255, 255, 255, 0.2); color: #fff; }

.side-foot { margin-top: auto; display: grid; gap: 0.5rem; }
.user-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-blue);
  border-radius: var(--r-md);
}
.user-card strong { display: block; font-size: 0.875rem; line-height: 1.3; }
.user-card small { display: block; font-size: 0.75rem; color: var(--subtle); line-height: 1.3; word-break: break-all; }
.logout {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  border: 0; background: none;
  border-radius: var(--r-md);
  color: var(--danger);
  font-weight: 600;
  font-size: 0.875rem;
}
.logout:hover { background: var(--danger-tint); }

.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.app-main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  height: 4rem;
  padding-inline: clamp(1rem, 0.5rem + 2vw, 2rem);
  background: rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 0.375rem; list-style: none; font-size: 0.875rem; color: var(--subtle); }
.crumbs li:last-child { color: var(--ink); font-weight: 600; }
.crumbs [data-lucide], .crumbs .lucide { width: 0.875rem; height: 0.875rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.bell { position: relative; }
.bell::after { content: ""; position: absolute; top: 0.625rem; right: 0.6875rem; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.a11y-mini { display: flex; gap: 0.25rem; }
.a11y-mini button {
  min-width: 2.5rem; height: 2.5rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.8125rem; font-weight: 700;
  display: grid; place-items: center;
}
.a11y-mini button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Content ---------- */
.app-content { padding: clamp(1rem, 0.5rem + 2vw, 2rem); max-width: 90rem; width: 100%; }
.app-content > section + section { margin-top: 1.5rem; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
  margin-bottom: 1.75rem;
}
.page-head h1 { font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem); margin-bottom: 0.375rem; }
.page-head p { color: var(--muted); margin: 0; max-width: 40rem; }
.page-head .eyebrow { margin-bottom: 0.5rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi {
  position: relative;
  padding: 1.25rem 1.375rem;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 0.25rem;
  min-height: 10.5rem;
}
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.kpi-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.kpi-value { font-family: var(--font-head); font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-top: 0.25rem; }
.kpi-value small { font-family: var(--font-body); font-size: 0.9375rem; font-weight: 500; color: var(--subtle); letter-spacing: 0; margin-left: 0.25rem; }
.kpi-foot { margin-top: auto; padding-top: 0.75rem; font-size: 0.8125rem; color: var(--muted); display: flex; align-items: center; gap: 0.375rem; }
.kpi-foot.up { color: var(--teal-dark); font-weight: 600; }
.kpi-foot [data-lucide], .kpi-foot .lucide { width: 1rem; height: 1rem; }

.split-bar { display: flex; height: 0.5rem; border-radius: var(--r-full); overflow: hidden; background: var(--divider); margin-top: 0.875rem; }
.split-bar span { display: block; height: 100%; transition: width 0.4s ease; }
.split-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 0.875rem; list-style: none; margin-top: 0.625rem; font-size: 0.75rem; color: var(--muted); }
.split-legend li { display: inline-flex; align-items: center; gap: 0.375rem; }
.split-legend i { width: 0.5rem; height: 0.5rem; border-radius: 2px; display: inline-block; }
.c-uwv { background: var(--primary); }
.c-wmo { background: var(--teal); }
.c-zorg { background: var(--sky); }
.c-werk { background: var(--amber); }

.kpi-hero {
  background: linear-gradient(145deg, #4f46e5, #3525cd 70%);
  border-color: transparent;
  color: #e0e7ff;
  box-shadow: var(--sh-3);
}
.kpi-hero .kpi-label { color: #c7d2fe; }
.kpi-hero .kpi-value { color: #fff; font-size: 2.25rem; }
.kpi-hero .kpi-foot { color: #c7d2fe; justify-content: space-between; }
.kpi-hero .icon-box { background: rgba(255, 255, 255, 0.14); color: #fff; }
.kpi-hero .badge { background: rgba(255, 255, 255, 0.16); color: #fff; border-color: rgba(255, 255, 255, 0.2); }

/* Werkgebied */
.work-grid { display: grid; grid-template-columns: minmax(20rem, 25rem) minmax(0, 1fr); gap: 1.5rem; align-items: start; }

.panel { padding: 1.5rem; }
.panel-head { display: flex; align-items: flex-start; gap: 0.875rem; margin-bottom: 1.5rem; }
.panel-head h2 { font-size: 1.25rem; margin-bottom: 0.125rem; }
.panel-head p { margin: 0; font-size: 0.875rem; color: var(--muted); }
.panel-head .badge { margin-left: auto; }
.panel-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.panel-head-row h2 { font-size: 1.25rem; margin-bottom: 0.125rem; }
.panel-head-row p { margin: 0; font-size: 0.875rem; color: var(--muted); }

.label-action {
  border: 0; background: none;
  padding: 0.125rem 0.25rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; font-weight: 600;
  color: var(--primary);
  border-radius: 0.25rem;
}
.label-action:hover { color: var(--primary-hover); text-decoration: underline; }
.label-action [data-lucide], .label-action .lucide { width: 0.875rem; height: 0.875rem; }

.scheme-grid { grid-template-columns: 1fr 1fr; grid-auto-flow: row; }

.calc {
  margin-top: 1.25rem;
  padding: 1.125rem 1.25rem;
  background: var(--bg-blue);
  border: 1px solid var(--primary-tint-2);
  border-radius: var(--r-lg);
}
.calc-top { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--primary-deep); margin-bottom: 0.5rem; }
.calc-top span { display: inline-flex; align-items: center; gap: 0.375rem; }
.calc-top [data-lucide], .calc-top .lucide { width: 0.9375rem; height: 0.9375rem; }
.calc-line { font-family: var(--font-head); font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; line-height: 1.35; }
.calc-total { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--primary-tint-2); font-size: 0.875rem; color: var(--muted); }
.calc-total strong { font-family: var(--font-head); font-size: 1.5rem; color: var(--teal-dark); letter-spacing: -0.02em; }
.calc.is-error { background: var(--danger-tint); border-color: #fecaca; }
.calc.is-error .calc-line { color: var(--danger); font-size: 0.9375rem; }

.form-actions { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-top: 1.25rem; }

.info-card {
  display: flex; gap: 0.875rem;
  padding: 1.125rem 1.25rem;
  background: var(--teal-tint);
  border: 1px solid var(--teal-border);
  border-radius: var(--r-lg);
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 1rem;
}
.info-card [data-lucide], .info-card .lucide { color: var(--teal); width: 1.25rem; height: 1.25rem; margin-top: 0.125rem; }
.info-card strong { display: block; color: var(--teal-dark); font-size: 0.875rem; margin-bottom: 0.125rem; }

/* Filters */
.filters {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-blue);
  border-radius: var(--r-lg);
  margin-bottom: 1rem;
}
.filters .input, .filters .select { border-color: transparent; }

/* Tabel */
.table-wrap { position: relative; overflow-x: auto; border-radius: var(--r-lg); }
.trips-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.trips-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}
.trips-table th.num, .trips-table td.num { text-align: right; }
.trips-table td { padding: 1rem; border-bottom: 1px solid var(--divider); vertical-align: top; }
.trips-table tbody tr:hover { background: var(--bg); }
.trip-main { display: flex; gap: 0.75rem; }
.trip-main .icon-box { width: 2.25rem; height: 2.25rem; border-radius: 0.625rem; }
.trip-title { font-weight: 600; color: var(--ink); line-height: 1.35; }
.trip-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; margin-top: 0.375rem; font-size: 0.75rem; color: var(--subtle); }
.cell-strong { font-weight: 600; color: var(--ink); white-space: nowrap; }
.cell-sub { display: block; font-size: 0.75rem; color: var(--subtle); white-space: nowrap; }
.amount { font-family: var(--font-head); font-weight: 700; color: var(--teal-dark); font-size: 1rem; white-space: nowrap; }
.row-del { width: 2.5rem; height: 2.5rem; border: 0; background: none; border-radius: var(--r-sm); color: var(--subtle); display: grid; place-items: center; }
.row-del:hover { color: var(--danger); background: var(--danger-tint); }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 1rem;
  font-size: 0.8125rem; color: var(--muted);
  flex-wrap: wrap;
}
.table-foot .summary { display: inline-flex; align-items: center; gap: 0.5rem; }
.table-foot .summary .dot { color: var(--emerald); }
.pages { display: flex; gap: 0.25rem; }
.pages button {
  min-width: 2.5rem; height: 2.5rem;
  padding-inline: 0.75rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.8125rem; font-weight: 600;
}
.pages button[aria-current="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.pages button:disabled { opacity: 0.45; cursor: default; }

.table-empty { text-align: center; padding: 2.5rem 1rem !important; color: var(--muted); }
.table-empty strong { display: block; color: var(--ink); margin-bottom: 0.25rem; }

.skeleton { background: linear-gradient(90deg, var(--divider), #fff, var(--divider)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 0.375rem; height: 1rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Beheer (voertuigen / standaard ritten) */
.manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.item-list { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); }
.item-list li { display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 0; border-top: 1px solid var(--divider); }
.item-list li:first-child { border-top: 0; }
.item-list .grow { flex: 1; min-width: 0; }
.item-list strong { display: block; font-size: 0.9375rem; overflow-wrap: anywhere; }
.item-list small { display: block; font-size: 0.8125rem; color: var(--subtle); }
.item-empty { color: var(--muted); font-size: 0.875rem; padding: 1rem 0; }

.gps-card { display: flex; align-items: center; gap: 1.25rem; padding: 1.5rem; background: var(--bg-blue); border-color: var(--primary-tint-2); }
.gps-card h2 { font-size: 1.125rem; margin-bottom: 0.25rem; }
.gps-card p { margin: 0; font-size: 0.875rem; color: var(--muted); }
.gps-card .btn { margin-left: auto; }

/* ---------- Dialogen ---------- */
dialog.modal {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  background: #fff;
  color: var(--ink);
  overflow: auto;
}
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 0.875rem; padding: 1.5rem 1.5rem 0.5rem; }
.modal-head h2 { font-size: 1.25rem; margin-bottom: 0.125rem; }
.modal-head p { margin: 0; font-size: 0.875rem; color: var(--muted); }
.modal-close { margin-left: auto; width: 2.5rem; height: 2.5rem; border: 0; background: none; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--subtle); flex-shrink: 0; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-body { padding: 1rem 1.5rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.5rem 1.5rem; }

/* Kenteken invoer */
.plate-input {
  display: flex;
  align-items: stretch;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 2px solid #ca8a04;
  background: #fcd34d;
  max-width: 16rem;
}
.plate-input::before {
  content: "NL";
  display: grid; place-items: end center;
  width: 2.25rem;
  padding-bottom: 0.375rem;
  background: #1d4ed8;
  color: #fef08a;
  font-weight: 700;
  font-size: 0.75rem;
}
.plate-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: #111827;
}
.plate-input input::placeholder { color: rgba(17, 24, 39, 0.35); }
.plate-input input:focus { outline: none; }
.plate-input:focus-within { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35); }
.plate-input[aria-invalid="true"] { border-color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .manage-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(18rem, 85vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--sh-3);
    visibility: hidden;
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, 0.35); }
  .sidebar-backdrop.is-open { display: block; }
  .sidebar-close { display: grid; position: absolute; top: 1rem; right: 0.75rem; }
  .sidebar .brand { padding-right: 3.5rem; }
  .menu-btn { display: grid; }
  .crumbs li:not(:last-child) { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn { flex: 1; }
}

@media (max-width: 760px) {
  .a11y-mini { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .kpi { min-height: 0; padding: 1rem; }
  .kpi .icon-box { display: none; }
  .kpi-value { font-size: 1.5rem; }
  .kpi-hero .kpi-value { font-size: 1.625rem; }
  .kpi-split, .kpi-hero { grid-column: 1 / -1; }
  .panel { padding: 1.125rem; }
  .trip-main .icon-box { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .input-icon { grid-column: 1 / -1; }
  .gps-card { flex-direction: column; align-items: flex-start; }
  .gps-card .btn { margin-left: 0; width: 100%; }

  /* Tabel wordt kaartjes */
  .trips-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .trips-table, .trips-table tbody, .trips-table tr, .trips-table td { display: block; }
  .trips-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.5rem 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: #fff;
  }
  .trips-table tbody tr:hover { background: #fff; }
  .trips-table td { padding: 0; border: 0; }
  .trips-table td.num { text-align: left; }
  .trips-table td[data-cell="rit"] { grid-column: 1 / 3; }
  .trips-table td[data-cell="actie"] { grid-column: 3; grid-row: 1; }
  .trips-table td[data-cell="datum"], .trips-table td[data-cell="km"] { padding-top: 0.625rem; border-top: 1px solid var(--divider); }
  .trips-table td[data-cell]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--subtle);
    margin-bottom: 0.125rem;
  }
  .trips-table td[data-cell="rit"]::before, .trips-table td[data-cell="actie"]::before { display: none; }
  .trips-table td[data-cell="bedrag"] { text-align: right; padding-top: 0.625rem; border-top: 1px solid var(--divider); }
  .trips-table td.table-empty { grid-column: 1 / -1; }
  .table-wrap { overflow: visible; }
  .table-foot { flex-direction: column; align-items: stretch; }
  .pages { justify-content: center; }

  dialog.modal {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  dialog.modal[open] { animation: sheet-in 0.22s ease-out; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .modal-foot .btn { flex: 1; min-height: 3rem; }
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .scheme-grid span { font-size: 0.75rem; }
}

/* ---------- Print (PDF-export in demomodus) ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .kpi-grid, .form-col, .filters, .pages, .row-del, .manage-grid, .gps-card, .toast-region, .skip-link, .panel-head-row .btn { display: none !important; }
  .app { display: block; }
  .work-grid { display: block; }
  .card { box-shadow: none; border: 0; }
  .trips-table tr { break-inside: avoid; }
  body { background: #fff; }
}
