/* =========================================================
   Swart 2.0 Backoffice - Sidebar styles
   Gebaseerd op Design System components-sidebar.html
   ========================================================= */

/* ==================== SIDEBAR ==================== */
.sb {
  --sb-w: 248px;
  width: var(--sb-w);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--border);
  font-size: 13px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

/* brand header */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sb-brand img {
  height: 22px;
  width: auto;
  display: block;
}
.sb-env {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-3);
  background: var(--bg-muted);
  padding: 3px 7px;
  border-radius: 999px;
}

/* ========== GROUP LABELS ========== */
.sb-group {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--fg-3);
  padding: 16px 0 5px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  text-align: left;
}
.sb-group:hover {
  color: var(--fg-1);
}
.sb-group .chev-group {
  width: 10px;
  height: 10px;
  color: currentColor;
  transition: transform .2s var(--ease-out);
  opacity: .55;
  flex: none;
}
.sb-group[aria-expanded="false"] .chev-group {
  transform: rotate(-90deg);
}
.sb-group[aria-expanded="false"] + ul {
  display: none;
}
.sb-group:focus-visible {
  outline: none;
  color: var(--fg-1);
}
.sb-group:focus-visible .chev-group {
  opacity: 1;
}

/* ========== NAV BODY ========== */
.sb-nav {
  padding: 4px 20px;
  flex: 1 1 auto;
  overflow-y: auto;
}
.sb-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ========== NAV ITEM ========== */
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 0;
  border-radius: var(--radius-md);
  color: var(--fg-2);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.2;
  position: relative;
  cursor: pointer;
  user-select: none;
  margin: 1px 0;
}
.nav-link .nav-ico {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-link .nav-ico svg {
  width: 18px;
  height: 18px;
  display: block;
}
.nav-link .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-link .nav-count,
.nav-link .nav-badge {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.45;
}
.nav-link .nav-count {
  background: var(--bg-muted);
  color: var(--fg-3);
}
.nav-link .nav-badge.red {
  background: #fee2e2;
  color: #991b1b;
}
.nav-link .nav-badge.blue {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}
.nav-link .nav-badge.soon {
  background: var(--bg-muted, #f3f4f6);
  color: var(--fg-3, #9ca3af);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* Hover */
.nav-link:hover {
  background: var(--bg-muted);
  color: var(--fg-1);
}
.nav-link:hover .nav-ico {
  color: var(--fg-2);
}

/* Active */
.nav-link.is-active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  font-weight: 600;
}
.nav-link.is-active .nav-ico {
  color: var(--ui-primary);
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--ui-primary);
  border-radius: 0 3px 3px 0;
}
.nav-link.is-active .nav-count {
  background: #fff;
  color: var(--ui-primary);
  box-shadow: 0 0 0 1px var(--ui-primary-ring) inset;
}

/* L1 - items inside a group get extra indent */
.sb-nav [id^="grp-"] > li > .nav-link {
  padding-left: 10px;
}

/* Focus ring */
.nav-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ui-primary-ring);
}

/* ========== EXPANDABLE CHILDREN ========== */
.nav-parent .nav-link .chev {
  width: 13px;
  height: 13px;
  color: var(--fg-3);
  transition: transform .15s var(--ease-out);
  opacity: .75;
  flex: none;
}
.nav-parent.open > .nav-link .chev {
  transform: rotate(90deg);
}

.sb-nav .nav-children {
  list-style: none;
  margin: 0 0 0 18px !important;
  padding: 0 0 0 9px !important;
  display: none;
}
.nav-children > li {
  position: relative;
}
.nav-children > li::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--border-strong);
}
.nav-children > li:last-child::before {
  bottom: 50%;
}
.nav-parent.open > .nav-children {
  display: block;
}
.nav-children .nav-link {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  margin: 0;
}
.nav-children > li > .nav-link::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  width: 9px;
  border-top: 1px dashed var(--border-strong);
}
.nav-children .nav-link.is-active {
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
}
.nav-children > li > .nav-link.is-active::before {
  left: -9px;
  top: 50%;
  width: 9px;
  height: auto;
  border-top: 1px dashed var(--ui-primary);
  background: none;
  border-radius: 0;
}

/* ========== DIVIDER ========== */
.sb-div {
  height: 1px;
  background: var(--border);
  margin: 10px 0;
}

/* ========== FOOTER ========== */
.sb-foot {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-foot-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sb-foot-nav .nav-link {
  padding: 6px 8px;
  font-size: 12.5px;
}
.sb-foot-nav .nav-link.is-active::before {
  left: -16px;
}
.sb-sync {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 4px 8px;
}
.sb-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
  flex: none;
}
.sb-sync-info b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-1);
}
.sb-sync-info span {
  font-size: 11px;
  color: var(--fg-3);
}

/* ==================== COLLAPSED RAIL - ICON ONLY ==================== */
/* Brand icon (verborgen op desktop-expanded, zichtbaar op tablet-rail) */
img.sb-brand-icon {
  display: none;
  width: auto;
  height: 28px;
  flex: none;
  object-fit: contain;
}

/* Close button (alleen zichtbaar op mobiel) */
.sb-close {
  display: none;
  border: none;
  background: none;
  color: var(--fg-3);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}
.sb-close:hover {
  background: var(--bg-muted);
  color: var(--fg-1);
}

/* Sidebar mobiel overlay backdrop - position:fixed neemt geen ruimte in de flow */
.sb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 22, 30, 0.5);
  z-index: 39;
}

/* ==================== TABLET: COLLAPSED RAIL (768-1023px) ==================== */
@media (max-width: 1023px) and (min-width: 768px) {
  .sb {
    --sb-w: 64px;
    width: var(--sb-w);
    align-items: stretch;
  }

  /* Brand: toon icon, verberg wordmark + env badge */
  .sb-brand {
    padding: 12px 0;
    justify-content: center;
  }
  .sb-brand .brand-wordmark { display: none; }
  img.sb-brand-icon { display: block; }
  .sb-env { display: none; }

  /* Nav: compact padding */
  .sb-nav {
    padding: 4px;
  }

  /* Verberg groep-labels, labels, counters, badges */
  .sb-group { display: none; }
  .sb-group + ul { display: block !important; }  /* Groepen altijd open in rail */
  .nav-label,
  .nav-count,
  .nav-badge,
  .chev { display: none; }

  /* Nav items: gecentreerd, alleen icoon - min 44px touch target */
  .nav-link {
    justify-content: center;
    padding: 11px 0;
    margin: 1px 4px;
    min-height: 44px;
    box-sizing: border-box;
  }
  .nav-link .nav-ico {
    width: 22px;
    height: 22px;
  }
  .nav-link .nav-ico svg {
    width: 22px;
    height: 22px;
  }

  /* Active accent rail aanpassen voor rail mode */
  .nav-link.is-active::before {
    left: -4px;
  }
  .sb-nav [id^="grp-"] > li > .nav-link {
    padding-left: 0;
  }

  /* Badge dot indicator (vervangt badge tekst) */
  .nav-link:has(.nav-badge.red)::after {
    content: "";
    position: absolute;
    top: 7px;
    right: 10px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #dc2626;
    border: 2px solid var(--bg-surface);
  }

  /* Footer: compact maar touch-safe */
  .sb-foot {
    padding: 10px 0;
    align-items: center;
  }
  .sb-foot-nav .nav-link {
    justify-content: center;
    padding: 11px 0;
    min-height: 44px;
  }
  .sb-foot-nav .nav-link .nav-label { display: none; }
  .sb-foot-nav .nav-link.is-active::before {
    left: -4px;
  }

  /* Sync info verbergen */
  .sb-sync {
    justify-content: center;
    padding: 4px 0;
  }
  .sb-sync-info { display: none; }
}

/* ==================== MOBIEL: SIDEBAR ALS OVERLAY (<768px) ==================== */
@media (max-width: 767px) {
  .sb {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--dur-slow, 0.3s) var(--ease-out, ease-out);
    box-shadow: none;
  }
  .sb.sb-mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,.2));
  }

  /* Brand: toon wordmark + close button (44px touch target) */
  .sb-brand .brand-wordmark { display: block; }
  img.sb-brand-icon { display: none; }
  .sb-env { display: inline-block; }
  .sb-close {
    display: inline-flex;
    margin-left: auto;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    margin-right: -8px;  /* visueel uitlijnen maar touch area behouden */
  }

  /* Nav-links: grotere touch targets (min 44px) */
  .nav-link {
    padding: 12px 10px 12px 0;
    min-height: 44px;
    box-sizing: border-box;
  }
  .sb-nav [id^="grp-"] > li > .nav-link {
    padding-left: 10px;
  }

  /* Groep-labels: extra ruimte */
  .sb-group {
    padding: 18px 0 6px 0;
    min-height: 36px;
  }

  /* Footer nav links: ook 44px */
  .sb-foot-nav .nav-link {
    padding: 12px 8px;
    min-height: 44px;
  }
}
