.topbar {
  height: 60px;
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 0 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.topbar-search {
  position: relative;
  flex: 0 1 360px;
  z-index: 1100; /* stay above .search-backdrop while a search is open */
}

.topbar-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 0.875rem;
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2.1rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  font-size: 0.875rem;
  color: var(--gray-700);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.topbar-search-input::placeholder { color: var(--gray-400); }

.topbar-search-input:focus {
  border-color: var(--brand-blue-light);
  box-shadow: 0 0 0 3px rgba(82,113,255,.12);
  background: var(--color-surface);
}

/* ── Global search: dim backdrop behind the dropdown ──
   Makes it unmistakably a floating layer above the page instead of
   looking like it "bleeds into" the dashboard content behind it. */
.search-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1040;
  opacity: 0;
  transition: opacity .15s ease;
}

.search-backdrop.visible { display: block; opacity: 1; }

/* ── Global search results dropdown ── */
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 380px;
  max-width: min(380px, calc(100vw - 2rem));
  max-height: min(60vh, 380px);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .08);
  padding: 0.4rem;
  z-index: 1050;
  animation: search-results-in .12s ease-out;
}

@keyframes search-results-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-results.visible { display: block; }

.search-results-status {
  padding: 0.75rem 0.75rem;
  font-size: 0.85rem;
  color: var(--gray-400);
}

.search-results-group-label {
  padding: 0.55rem 0.6rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-400);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--gray-700);
}

.search-result-item:hover,
.search-result-item.highlighted {
  background: var(--gray-100);
  color: var(--gray-900);
}

.search-result-icon {
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
  color: var(--color-primary-text);
  font-size: 0.95rem;
}

.search-result-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.search-result-title {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-subtitle {
  font-size: 0.75rem;
  color: var(--gray-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--gray-500);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background .12s, color .12s;
}

.topbar-icon-btn:hover { background: var(--gray-100); color: var(--gray-900); }

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .03em;
  flex-shrink: 0;
}

.user-avatar--md {
  width: 38px;
  height: 38px;
  font-size: 0.85rem;
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-700);
  font-size: 0.875rem;
  transition: background .12s;
}

.topbar-user-btn:hover { background: var(--gray-100); }
.topbar-user-btn::after { display: none; }

.topbar-name { font-weight: 500; }

.topbar-dropdown {
  min-width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  padding: 0.5rem 0;
}

.topbar-dropdown .dropdown-header {
  padding: 0.6rem 1rem 0.8rem;
  color: var(--gray-700);
}

.topbar-dropdown .dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  display: flex;
  align-items: center;
}

.topbar-dropdown .dropdown-item:hover { background: var(--gray-50); }
.topbar-dropdown .dropdown-item.text-danger:hover { background: var(--tint-red-50); }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: 8px;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--gray-100);
}

/* Hamburger nur auf dem Handy: auf dem Desktop ist die Sidebar fest sichtbar.
   Muss hier stehen, weil topbar.css nach sidebar.css geladen wird und display:flex sonst gewinnt. */
@media (min-width: 768px) {
  .sidebar-toggle {
    display: none;
  }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-700);
}

.topbar-rolle {
  font-size: 0.75rem;
  background: var(--brand-blue);
  color: #fff;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
