/* ============================================================
   sidebar.css — Topbar, Sidebar, Toggle
   ============================================================ */

:root {
  --sidebar-w: 300px;
  --topbar-h:  70px;
  --transition: .3s cubic-bezier(.4,0,.2,1);
}

/* ══ TOPBAR ══ */
#topBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center;
  padding: 0 1.75rem;
  gap: 1rem; z-index: 900;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-logo {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.2rem;
  letter-spacing: -.02em; color: var(--text-1);
  display: flex; align-items: center; gap: .6rem; flex: 1;
  margin-left: calc(48px + .75rem);
  transition: margin-left var(--transition);
}
body.sidebar-open .topbar-logo { margin-left: 0; }

.topbar-logo-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 12px var(--brand);
  animation: topbarPulse 2.4s ease-in-out infinite; flex-shrink: 0;
}
@keyframes topbarPulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.5; transform:scale(.8); }
}

/* ══ TOGGLE ══ */
#sidebarToggle {
  position: fixed;
  top: calc((var(--topbar-h) - 56px) / 2);
  left: 14px;
  z-index: 1001;
  width: 56px; height: 56px;
  background: var(--brand);
  border: none; border-radius: var(--r-sm);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,160,221,.45);
  transition: background .2s, box-shadow .2s, transform .15s;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; padding: 0;
}
#sidebarToggle:hover {
  background: var(--brand-dark);
  box-shadow: 0 6px 26px rgba(0,160,221,.65);
}
#sidebarToggle:active { transform: scale(.92); }

#sidebarToggle span {
  display: block; width: 26px; height: 2.5px;
  background: #fff; border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition), width var(--transition);
  pointer-events: none;
}
body.sidebar-open #sidebarToggle span:nth-child(1) { transform: translateY(8.5px) rotate(45deg); }
body.sidebar-open #sidebarToggle span:nth-child(2) { opacity: 0; width: 0; }
body.sidebar-open #sidebarToggle span:nth-child(3) { transform: translateY(-8.5px) rotate(-45deg); }

/* ══ OVERLAY ══ */
#sidebarOverlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px); z-index: 840;
}
@media (max-width: 1023px) {
  #sidebarOverlay.show { display: block; }
}

/* ══ SIDEBAR ══ */
#sidebarMenu {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border-2);
  display: flex; flex-direction: column;
  z-index: 850;
  overflow-y: auto; overflow-x: hidden;
  transform: translateX(-100%);
  transition: transform var(--transition);
}
#sidebarMenu::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}
#sidebarMenu.show { transform: translateX(0); }

/* Brand Block */
.sidebar-brand {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.5rem 1.5rem 1.2rem;
  margin-top: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
  box-shadow: 0 0 22px rgba(0,160,221,.4);
}
.sidebar-brand-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.1rem; color: var(--text-1); line-height: 1.2;
}
.sidebar-brand-sub { font-size: .8rem; color: var(--text-3); margin-top: .15rem; }

/* Nav */
#sidebarMenu ul { list-style: none; padding: 1rem .8rem 0; flex: 1; }
#sidebarMenu ul li { margin-bottom: 3px; }

#sidebarMenu ul li a,
#sidebarMenu ul li .menu-btn {
  display: flex; align-items: center; gap: .95rem;
  width: 100%;
  padding: 1rem 1.15rem;
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  background: none; border: none;
  border-left: 3px solid transparent;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  cursor: pointer; text-align: left;
  transition: background .15s, color .15s, border-color .15s, padding-left .15s;
  min-height: 54px;
  -webkit-appearance: none;
  white-space: nowrap;
}
#sidebarMenu ul li a:hover,
#sidebarMenu ul li .menu-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
  padding-left: 1.4rem;
  text-decoration: none;
}
#sidebarMenu ul li a.active,
#sidebarMenu ul li .menu-btn.active {
  background: rgba(0,160,221,.14);
  color: var(--brand);
  font-weight: 600;
  border-left-color: var(--brand);
}

/* Abmelden */
#sidebarMenu ul li:last-child {
  border-top: 1px solid var(--border);
  padding-top: .4rem; margin-top: .85rem;
}
#sidebarMenu ul li:last-child .menu-btn { color: var(--text-3); }
#sidebarMenu ul li:last-child .menu-btn:hover {
  background: rgba(244,63,94,.1); color: var(--red);
}

/* ══ CONTENT OFFSET ══ */
.main-container,
.admin-container,
.user-overview-container,
.user-edit-container,
.qr-code-scanner-container,
.logs-container,
.page-wrapper {
  margin-left: 0;
  transition: margin-left var(--transition);
}

@media (min-width: 1024px) {
  body.sidebar-open .main-container,
  body.sidebar-open .admin-container,
  body.sidebar-open .user-overview-container,
  body.sidebar-open .user-edit-container,
  body.sidebar-open .qr-code-scanner-container,
  body.sidebar-open .logs-container,
  body.sidebar-open .page-wrapper {
    margin-left: var(--sidebar-w);
  }
  #sidebarOverlay { display: none !important; }
}

@media (max-width: 420px) {
  #sidebarMenu { width: min(88vw, var(--sidebar-w)); }
}

/* ══ MOBILE SIDEBAR ══ */
@media (max-width: 768px) {

  /* Topbar-Logo ausblenden wenn Sidebar zu — mehr Platz */
  .topbar-logo {
    font-size: 1rem !important;
  }

  /* Sidebar voller Screen auf kleinen Phones */
  #sidebarMenu {
    width: min(88vw, var(--sidebar-w)) !important;
  }

  /* Nav-Items auf Mobile etwas kompakter */
  #sidebarMenu ul li a,
  #sidebarMenu ul li .menu-btn {
    font-size: .97rem !important;
    min-height: 50px !important;
    padding: .85rem 1rem !important;
  }

  /* Brand-Block kompakter */
  .sidebar-brand {
    padding: 1rem 1.1rem .85rem !important;
  }
  .sidebar-brand-icon {
    width: 40px !important;
    height: 40px !important;
  }
  .sidebar-brand-name { font-size: .95rem !important; }
}

@media (max-width: 480px) {
  /* Sidebar auf sehr kleinen Phones fast fullscreen */
  #sidebarMenu {
    width: 92vw !important;
  }
}

/* ══ SIDEBAR MOBILE OPTIMIERUNGEN ══ */
@media (max-width: 1023px) {

  /* Sidebar: 85% Breite auf Mobile */
  #sidebarMenu {
    width: 85vw !important;
    max-width: 360px !important;
  }

  /* Brand Block größer */
  .sidebar-brand {
    padding: 1.5rem 1.5rem 1.25rem !important;
  }
  .sidebar-brand-icon {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.4rem !important;
  }
  .sidebar-brand-name {
    font-size: 1.1rem !important;
  }
  .sidebar-brand-sub {
    font-size: .8rem !important;
  }

  /* Nav Items größer & mehr Abstand */
  #sidebarMenu ul {
    padding: 1rem .75rem 0 !important;
  }
  #sidebarMenu ul li {
    margin-bottom: 4px !important;
  }
  #sidebarMenu ul li a,
  #sidebarMenu ul li .menu-btn {
    font-size: 1.05rem !important;
    min-height: 54px !important;
    padding: .9rem 1.25rem !important;
    border-radius: 12px !important;
  }

  /* Toggle Button größer */
  #sidebarToggle {
    width: 48px !important;
    height: 48px !important;
    top: calc((var(--topbar-h) - 48px) / 2) !important;
  }
  #sidebarToggle span {
    width: 22px !important;
  }

  /* Topbar höher */
  #topBar {
    height: 68px !important;
  }
}

@media (max-width: 480px) {
  /* Sehr kleine Phones: Sidebar fast fullscreen */
  #sidebarMenu {
    width: 88vw !important;
  }

  /* Abmelden mehr Platz */
  #sidebarMenu ul li:last-child {
    margin-top: 1rem !important;
    padding-top: .5rem !important;
  }
}


/* ── Kein horizontales Scrollen wenn Sidebar offen ── */
@media (max-width: 1023px) {
  body.sidebar-open {
    overflow-x: hidden;
  }

  body.sidebar-open .content,
  body.sidebar-open .main-container,
  body.sidebar-open .page-wrapper,
  body.sidebar-open .logs-container,
  body.sidebar-open .user-edit-container,
  body.sidebar-open .user-overview-container,
  body.sidebar-open .qr-code-scanner-container {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
}


/* ── Mobile: Titel neben Hamburger ── */
@media (max-width: 1023px) {
  .page-box-header,
  .page-box > .page-box-header {
    padding-left: 4.5rem !important;
  }
}
