:root {
  --bg-primary: #f4f6fa;
  --bg-secondary: #fff;
  --bg-sidebar: #fff;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #8a929a;
  --border-color: #dee2e6;
  --shadow: rgba(80, 90, 100, 0.02);
  --nav-hover: #e3f2fd;
  --nav-active: #e3f2fd;
  --brand-color: #1976d2;
  --white: #fff;
  --black: #000;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  height: 60px;
  background: var(--brand-color);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 1px;
  flex-shrink: 0;
  justify-content: flex-start;
  gap: 1rem;
  position: relative;
}

#sidebarToggle {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  height: calc(100vh - 60px - 40px);
  overflow: hidden;
}

.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  box-shadow: 2px 0 8px var(--shadow);
  padding: 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 60px;
  height: calc(100vh - 116px);
  overflow-y: auto;
  max-height: 100%;
  transition: transform 0.2s ease-in-out;
  z-index: 1050;
  transform: translateX(0);
  font-size: clamp(12px, 1.6vw, 16px); /* Schaalt sidebar-tekst automatisch */
  line-height: 1.4;
}

.sidebar.hide {
  transform: translateX(-100%);
}

.sidebar .brand {
  font-size: 18px;
  font-weight: 1000;
  color: var(--brand-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0.8rem 0.8rem 0.8rem;
}

.sidebar .nav-category,
.sidebar .nav-category-collapsible {
  color: var(--text-muted);
  font-size: clamp(11px, 1.3vw, 14px);
  text-transform: uppercase;
  margin: 0.2rem 0 0.2rem 0.6rem;
  font-weight: 600;
  user-select: none;
}

.sidebar .nav-link {
  color: var(--text-secondary);
  border-radius: 0.4rem;
  margin-bottom: 0.1rem; /* minimale marge */
  font-size: clamp(13px, 2vw, 18px); /* schaalbare tekst, groot bij breed scherm */
  padding: 0.3rem 0.6rem;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 32px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: var(--nav-hover);
  color: var(--brand-color) !important;
  text-decoration: none;
}

.sidebar .nav-link.active {
  background: var(--nav-active);
  font-weight: 900;
}

.sidebar .nav-category-collapsible {
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.4rem;
  transition: background .2s, color .2s;
  margin: 0.5rem 0 0.2rem;
  padding: 0.25rem 0.6rem;
  background: none;
  border: none;
  user-select: none;
}

.sidebar .nav-category-collapsible:hover {
  background: var(--nav-hover);
  color: var(--brand-color);
}

.sidebar .nav-category-collapsible .chevron {
  transition: transform 0.25s;
  display: inline-block;
  font-size: 1rem;
  margin-left: 0.4rem;
}

.sidebar .nav-category-collapsible.chevron-open .chevron {
  transform: rotate(90deg);
}

.nav-submenu {
  margin-left: 0.6rem;
  border-left: 2px solid var(--border-color);
  padding-left: 0.4rem;
  margin-bottom: 0.25rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-submenu.show {
  max-height: 600px;
}

.nav-submenu .nav-link {
  margin-bottom: 0.05rem;
  padding: 0.25rem 0.6rem;
  font-size: clamp(12px, 1.6vw, 16px);
  min-height: 28px;
}

.content-wrap {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  margin-left: 240px;
}

.iframe-container {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  position: relative;
}

#contentFrame {
  border: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-secondary);
}

footer {
  height: 40px;
  background: var(--brand-color);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  user-select: none;
}

#sidebarBackdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  z-index: 1040;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

#sidebarBackdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px - 40px);
    transform: translateX(-100%);
    max-height: calc(100vh - 60px - 40px);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.13);
    background: var(--bg-sidebar);
    margin-left: 0;
    z-index: 1050;
    font-size: clamp(12px, 2.5vw, 15px);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .content-wrap {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  header {
    font-size: 1rem;
    height: 48px;
  }

  .sidebar {
    width: 200px;
  }

  .sidebar .nav-link {
    font-size: clamp(12px, 4vw, 16px);
    padding: 0.25rem 0.5rem;
  }
}
