/* Topbar: fixe Kopfleiste über die volle Anwendungsbreite, vor der
   Sidebar (diese beginnt erst unterhalb der Topbar). */

:root {
  --topbar-height: 64px;
  /* Abstand zwischen Topbar und Seiteninhalt. */
  --topbar-gap: 24px;
}

body.has-topbar {
  padding-top: calc(var(--topbar-height) + var(--topbar-gap));
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

/* Menü-Button für den Navigations-Drawer (sidebar.js): nur im
   Mobile-Layout, ganz links vor dem Logo. */
.topbar-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0 8px 0 -4px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-nav-toggle svg {
  width: 24px;
  height: 24px;
}

.topbar-nav-toggle:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.topbar-nav-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #bfdbfe;
}

/* Logo: links, führt zur Startseite; so hoch wie das Profil-Icon. */
.topbar-logo {
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.topbar-logo img {
  display: block;
  width: 40px;
  height: 40px;
}

.topbar-logo:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #bfdbfe;
}

/* Profil-Icon: fest im rechten Bereich der Topbar. */
.topbar-profile {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.topbar-profile svg {
  width: 22px;
  height: 22px;
}

/* Hochgeladener Avatar füllt die runde Fläche. */
.topbar-profile img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.topbar-profile:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.topbar-profile:focus-visible {
  outline: none;
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: 0 0 0 3px #bfdbfe;
}

/* Profil-Menü: öffnet unter dem Profil-Icon, rechtsbündig. */
.topbar-menu {
  position: absolute;
  top: calc(var(--topbar-height) - 8px);
  right: 24px;
  min-width: 200px;
  padding: 6px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.16);
}

.topbar-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

/* display: block oben würde sonst das hidden-Attribut aushebeln
   (Einführungstour-Eintrag auf Seiten ohne tour.js). */
.topbar-menu-item[hidden] {
  display: none;
}

.topbar-menu-item:hover,
.topbar-menu-item:focus-visible {
  outline: none;
  background: #f1f5f9;
  color: #0f172a;
}

/* Mobile-Layout — schmal oder niedrig (Handy im Querformat), gleiche Query
   wie MOBILE_NAV_QUERY in sidebar.js: kompaktere Topbar, Menü-Button statt
   dauerhaft sichtbarer Sidebar. */
@media (max-width: 640px), (max-height: 500px) {
  :root {
    --topbar-height: 56px;
    --topbar-gap: 12px;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-nav-toggle {
    display: flex;
    width: 44px;
    height: 44px;
  }

  .topbar-logo img {
    width: 36px;
    height: 36px;
  }

  .topbar-profile {
    width: 36px;
    height: 36px;
  }

  .topbar-profile svg {
    width: 20px;
    height: 20px;
  }

  .topbar-menu {
    right: 12px;
  }
}
