/* ==========================================================================
   Top Bar — slim, fixed app header
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background-color: var(--color-primary-dark);
  border-bottom: 1px solid var(--tint-white-10);
  box-shadow: var(--shadow-sm);
  height: var(--topbar-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-topbar);
}

.topbar__section {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar__section--center {
  flex-grow: 1;
  margin: 0 var(--space-8);
}

.topbar__section--right {
  gap: var(--space-2);
}

.topbar__logo {
  height: 40px;
  width: auto;
  display: block;
}

/* Quick search — glassy field on the dark bar */
.topbar__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background-color: var(--tint-white-10);
  border: 1px solid var(--tint-white-16);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  height: 38px;
  width: 260px;
  max-width: 100%;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.topbar__search:hover,
.topbar__search:focus-within {
  background-color: var(--tint-white-16);
  border-color: var(--tint-white-24);
}

.topbar__search-input {
  border: none;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: var(--font-size-medium);
  font-family: var(--font-family-base);
  color: var(--color-white);
}

.topbar__search-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.topbar__search-icon {
  width: 18px;
  height: 18px;
  color: rgba(255, 255, 255, 0.65);
  flex-shrink: 0;
}

/* Icon actions */
.topbar__option {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  width: 38px;
}

.topbar__option-icon {
  width: 22px;
  height: 22px;
  color: var(--color-white);
}

.topbar__settings-link,
.topbar__notifications-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-white);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-base);
  position: relative;
}

.topbar__settings-link:hover,
.topbar__notifications-link:hover {
  background-color: var(--tint-white-16);
}

.topbar__notifications-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar__notifications-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1rem;
  color: var(--color-white);
  background-color: var(--color-danger);
  border: 2px solid var(--color-primary-dark);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   The account menu — the avatar, and what hangs off it

   Hover-opened, like the sidenav's Business fly-out, and :focus-within opens it
   for a keyboard as well. No JavaScript, so it also works on the screens that
   load none.
   ========================================================================== */
.topbar__user {
  position: relative;
}

.topbar__user-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-full);
}

.topbar__user-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.topbar__user-menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 240px;
  padding: var(--space-2);
  background-color: var(--color-primary-green);
  border: 1px solid var(--tint-white-16);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1;
}

.topbar__user:hover .topbar__user-menu,
.topbar__user:focus-within .topbar__user-menu {
  display: block;
}

/* Bridges the gap between the avatar and the menu, so crossing it with the
   pointer does not close what you are reaching for. */
.topbar__user:hover::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  height: var(--space-2);
}

.topbar__user-identity {
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--tint-white-16);
}

.topbar__user-name {
  font-family: var(--font-family-bold);
  font-weight: 600;
  font-size: var(--font-size-medium);
  color: var(--color-white);
}

.topbar__user-email {
  font-size: var(--font-size-small);
  color: rgba(255, 255, 255, 0.7);
  overflow-wrap: anywhere;
}

.topbar__user-menu-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-medium);
  color: var(--color-white);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-base);
}

.topbar__user-menu-link:hover {
  background-color: var(--tint-white-16);
}

/* The tenant switcher: the tenant this is, then a form per other tenant. The
   buttons wear the link style, so they need the button's own chrome taken off. */
.topbar__user-tenants {
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--tint-white-16);
}

.topbar__user-tenant-current {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-family-bold);
  font-weight: 600;
  font-size: var(--font-size-medium);
  color: var(--color-white);
}

.topbar__user-menu-form {
  margin: 0;
}

button.topbar__user-menu-link {
  font-family: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.topbar__user-menu-icon {
  flex-shrink: 0;
  color: var(--color-white);
}
