/* ============================================================
   Factuursysteem — Hoofdstijlblad  v3
   ============================================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-accent: #3b82f6;
  --topbar-h: 56px;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
}

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

body {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: var(--body-bg);
  color: var(--text-main);
  margin: 0;
}

/* ---- Sidebar layout ---- */
.wrapper { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  overflow: hidden;
}
#sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo { max-height: 48px; max-width: 100px; object-fit: contain; }
.sidebar-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 16px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.sidebar-nav .nav-section {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: #475569; padding: 14px 16px 4px;
}
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--sidebar-text);
  text-decoration: none; border-radius: 6px;
  margin: 1px 8px; transition: background .15s, color .15s; font-size: 13.5px;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active { background: rgba(59,130,246,.15); color: #fff; }
.sidebar-nav li a.active { background: var(--sidebar-accent); }
.sidebar-nav li a i { font-size: 16px; width: 18px; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 6px;
}
.btn-logout {
  color: #94a3b8; font-size: 13px; text-decoration: none;
  display: flex; align-items: center; gap: 6px; transition: color .15s;
}
.btn-logout:hover { color: #fff; }
.sidebar-footer small { color: #475569; font-size: 11px; }

/* ---- Hoofdinhoud ---- */
#content {
  margin-left: var(--sidebar-width);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; transition: margin .25s ease;
}
#content.expanded { margin-left: 0; }

.topbar {
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px;
  position: sticky; top: 0; z-index: 999; box-shadow: var(--shadow);
}
#sidebarToggle {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px;
  color: var(--text-muted); cursor: pointer;
}
.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

.page-content { padding: 24px; flex: 1; }

/* ---- Kaarten ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  padding: 14px 18px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 18px; }

/* ---- Statistiek kaarten ---- */
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 700; font-family: 'Outfit', sans-serif; }

/* ---- Tabellen ---- */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table { margin: 0; font-size: 13.5px; }
.table thead th {
  background: #f8fafc; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  padding: 10px 14px; white-space: nowrap;
}
.table tbody td { padding: 10px 14px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Formulieren ---- */
.form-label { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.form-control, .form-select {
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13.5px; padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--sidebar-accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15); outline: none;
}
.input-group-text { background: #f8fafc; border: 1px solid var(--border); font-size: 13.5px; }

/* ---- Knoppen ---- */
.btn { border-radius: 7px; font-size: 13.5px; font-weight: 500; padding: 7px 14px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1e40af; border-color: #1e40af; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }

/* ---- Paginatitel ---- */
.page-title {
  font-family: 'Outfit', sans-serif; font-size: 22px;
  font-weight: 700; color: var(--text-main); margin-bottom: 0;
}

/* ============================================================
   Document regeleditor
   ============================================================ */

/* Wrapper: horizontaal scrollbaar als scherm te smal */
.regels-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--radius) var(--radius);
}

.regels-tabel {
  table-layout: auto;
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  margin: 0;
}

.regels-tabel th {
  vertical-align: middle;
  padding: 9px 8px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.regels-tabel td {
  vertical-align: middle;
  padding: 5px 5px;
  border-bottom: 1px solid #f1f5f9;
}

.regels-tabel tbody tr:last-child td { border-bottom: none; }

/* Kolom-breedtes */
.regels-tabel .drag-col         { width: 28px; padding: 5px 2px; }
.regels-tabel .omschrijving-col { min-width: 200px; position: relative; }
.regels-tabel .aantal-col       { width: 90px; }
.regels-tabel .prijs-col        { width: 105px; }
.regels-tabel .korting-col      { width: 100px; }
.regels-tabel .btw-col          { width: 115px; }
.regels-tabel .totaal-col       { width: 90px; text-align: right; font-weight: 600; white-space: nowrap; padding-right: 8px; }
.regels-tabel .verwijder-col    { width: 40px; text-align: center; }

/* Alle invoervelden in de tabel: breedte van kolom */
.regels-tabel input.form-control,
.regels-tabel select.form-select {
  width: 100%;
  min-width: 0;
  font-size: 13px;
  padding: 5px 7px;
}

/* BTW select: iets kleiner zodat de tekst past */
.btw-select {
  font-size: 12px !important;
  padding: 5px 4px !important;
}

/* Kortingveld: %-teken netjes naast het invoerveld */
.korting-col .input-group { flex-wrap: nowrap; }
.korting-col .input-group-text { padding: 0 6px; font-size: 12px; }
.korting-col .form-control { padding: 5px 4px; }

/* Aantal: rechts uitlijnen */
.aantal-field { text-align: right; }

/* Sleephandle */
.sorteer-handle { cursor: grab; color: #cbd5e1; font-size: 16px; }
.sorteer-handle:active { cursor: grabbing; }

/* ---- Artikel-suggesties dropdown ---- */
.artikel-suggesties {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 380px;
  max-width: 560px;
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 2000;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
  background: #fff;
}
.artikel-suggesties .suggestie-header {
  padding: 6px 12px 5px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: #f8fafc;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  position: sticky; top: 0; z-index: 1;
}
.artikel-suggesties .list-group-item {
  border-left: none; border-right: none;
  font-size: 13px; cursor: pointer;
  padding: 9px 14px; border-radius: 0;
  line-height: 1.4;
}
.artikel-suggesties .list-group-item:last-child {
  border-bottom: none;
  border-radius: 0 0 8px 8px;
}
.artikel-suggesties .list-group-item:hover { background: #eff6ff; }
.artikel-suggesties .suggestie-leeg {
  padding: 10px 14px; font-size: 13px;
  color: var(--text-muted); font-style: italic;
}
.artikel-suggesties mark {
  background: #fef08a; border-radius: 2px; padding: 0 1px;
}

/* ---- Totaalblok ---- */
.totaal-blok {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 16px;
}
.totaal-rij {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 13.5px;
}
.totaal-rij.groot {
  font-weight: 700; font-size: 15px;
  padding-top: 8px; border-top: 2px solid var(--border); margin-top: 4px;
}

/* ---- Print/PDF preview ---- */
.document-preview {
  background: #fff; padding: 40px;
  border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 820px; margin: 0 auto; box-shadow: var(--shadow-md);
}

/* ---- Alerts ---- */
.alert { border-radius: 8px; font-size: 13.5px; }

/* ---- Badges ---- */
.badge { font-size: 11px; font-weight: 500; padding: 4px 8px; border-radius: 5px; }

/* ---- Zoekbalk ---- */
.zoek-wrap { position: relative; }
.zoek-wrap input { padding-left: 32px; }
.zoek-wrap .bi { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* ---- Login pagina ---- */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border-radius: 14px; padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-family: 'Outfit', sans-serif; font-size: 26px; font-weight: 700; color: var(--text-main); }

/* ---- Responsief ---- */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
    z-index: 1050;
  }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0 !important; }
  .page-content { padding: 14px; }
  .topbar { padding: 0 14px; }

  /* Overlay achter sidebar op mobiel */
  #sidebarOverlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1040;
  }
  #sidebarOverlay.active { display: block; }

  /* Grotere touch targets */
  .sidebar-nav li a { padding: 11px 16px; font-size: 14px; }
  .btn-logout { padding: 8px 0; font-size: 14px; }

  /* Tabel responsief */
  .table-responsive { font-size: 12px; }

  /* Kaarten full width */
  .stat-card { padding: 12px; }
}

@media (max-width: 480px) {
  .page-content { padding: 10px; }
  h1.page-title { font-size: 18px; }
  .btn { font-size: 13px; padding: 6px 10px; }
}

/* ---- Kleurpicker ---- */
.kleur-picker-wrap { display: flex; align-items: center; gap: 8px; }
.kleur-picker-wrap input[type=color] {
  width: 44px; height: 34px; border-radius: 6px;
  border: 1px solid var(--border); cursor: pointer; padding: 2px;
}

/* ============================================================
   BerFak Software — Branding
   ============================================================ */

.berfak-credit {
  margin-top: 4px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 1px;
}
.berfak-credit span {
  font-size: 9px; text-transform: uppercase;
  letter-spacing: .08em; color: #334155;
}
.berfak-credit strong {
  font-size: 11px; font-family: 'Outfit', sans-serif;
  font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.app-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px; border-top: 1px solid var(--border);
  background: #fff; font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.app-footer-sep { color: var(--border); }
.app-footer-brand { display: flex; align-items: center; gap: 5px; }
.app-footer-brand strong {
  font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 12px;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.app-footer-brand .bi { font-size: 13px; color: #3b82f6; }
.app-footer-version { font-size: 11px; color: #94a3b8; font-family: monospace; }

.login-berfak {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center; display: flex;
  align-items: center; justify-content: center;
  gap: 6px; font-size: 12px; color: #94a3b8;
}
.login-berfak .bi { font-size: 13px; color: #3b82f6; }
.login-berfak span {
  font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 13px;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ---- Sticky opslaan balk ---- */
.sticky-opslaan {
  position: sticky;
  bottom: 16px;
  display: flex;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100;
}
