// Trigger — avatar (initials in a small square) + chevron. The
// outer shape mirrors gitea/github: square-ish with a small chevron
// hint. Each host app can recolor the avatar via the
// `--user-menu-avatar-bg` / `--user-menu-avatar-fg` CSS variables
// so the brand color stays consistent with the surrounding header.
.user-menu__trigger {
  --user-menu-avatar-bg: var(--color-brand-primary-500, #2563eb);
  --user-menu-avatar-fg: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.75rem;
  padding: 0.25rem 0.5rem;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease-out;

  &:hover {
    background-color: rgba(0, 0, 0, 0.06);

    :where(.dark) & {
      background-color: rgba(255, 255, 255, 0.08);
    }
  }

  &:focus-visible {
    outline: 2px solid var(--color-brand-primary-500, #2563eb);
    outline-offset: 2px;
  }
}

.user-menu__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  background-color: var(--user-menu-avatar-bg);
  color: var(--user-menu-avatar-fg);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

// Panel — CDK Menu opens this in an overlay portal at the document
// root. ViewEncapsulation.None on the component lets these styles
// reach it.
.user-menu__panel {
  min-width: 14rem;
  margin-top: 0.25rem;
  padding: 0.25rem 0;
  background-color: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);

  :where(.dark) & {
    background-color: #111827;
    color: #f3f4f6;
    border-color: #1f2937;
    box-shadow:
      0 10px 15px -3px rgba(0, 0, 0, 0.4),
      0 4px 6px -4px rgba(0, 0, 0, 0.4);
  }
}

.user-menu__header {
  padding: 0.5rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.user-menu__header-label {
  font-size: 0.6875rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;

  :where(.dark) & {
    color: #9ca3af;
  }
}

.user-menu__header-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: inherit;
}

.user-menu__header-username {
  font-size: 0.75rem;
  color: #6b7280;

  :where(.dark) & {
    color: #9ca3af;
  }
}

.user-menu__separator {
  height: 1px;
  margin: 0.25rem 0;
  background-color: #e5e7eb;

  :where(.dark) & {
    background-color: #1f2937;
  }
}

.user-menu__group {
  display: flex;
  flex-direction: column;
  padding: 0.125rem 0;
}

.user-menu__item {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.875rem;
  background: transparent;
  border: 0;
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;

  &:hover,
  &:focus-visible {
    background-color: rgba(0, 0, 0, 0.04);
    outline: none;

    :where(.dark) & {
      background-color: rgba(255, 255, 255, 0.06);
    }
  }
}

.user-menu__item--disabled {
  color: #9ca3af;
  cursor: default;

  &:hover {
    background-color: transparent;
  }

  :where(.dark) & {
    color: #6b7280;
  }
}

.user-menu__item--sign-out {
  color: #b91c1c;

  :where(.dark) & {
    color: #fca5a5;
  }
}

.user-menu__icon {
  display: inline-flex;
  width: 1.125rem;
  flex: 0 0 1.125rem;
}

.user-menu__label {
  flex: 1 1 auto;
}

.user-menu__badge {
  font-size: 0.625rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  background-color: rgba(0, 0, 0, 0.06);
  color: #6b7280;

  :where(.dark) & {
    background-color: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
  }
}
